Unable to Run 'bundle exec jekyll serve' (beginner's issue)

Hello, my first time using Jekyll (for an online course) and also first time posting here. I’ve searched around for any solutions provided for the error I came across during my initial setup.

I wanted to preview the site after its first installation (I haven’t made any changes yet, I just wanted to preview it on my web browser), so I typed in the bundle exec jekyll serve on my Terminal. Unfortunately, this was what I got:

Configuration file: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adrianne-dev/_config.yml
            Source: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adrianne-dev
       Destination: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adrianne-dev/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
                    done in 0.668 seconds.
 Auto-regeneration: enabled for '/Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adrianne-dev'
                    ------------------------------------------------
      Jekyll 4.2.0   Please append `--trace` to the `serve` command
                     for any additional information or backtrace.
                    ------------------------------------------------

It’s supposed to give me an IP address that I can use to preview the newly-built Jekyll site on my browser, but I didn’t see it. I went ahead and entered bundle exec jekyll serve --trace and here are my results:

Configuration file: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adrianne-dev/_config.yml
            Source: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adrianne-dev
       Destination: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adrianne-dev/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
                    done in 0.64 seconds.
 Auto-regeneration: enabled for '/Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adrianne-dev'
bundler: failed to load command: jekyll (/Users/adriculous/.gem/ruby/2.6.0/bin/jekyll)
Traceback (most recent call last):
	39: from /Users/adriculous/.gem/ruby/2.6.0/bin/bundle:23:in `<main>'
	38: from /Users/adriculous/.gem/ruby/2.6.0/bin/bundle:23:in `load'
	37: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/exe/bundle:37:in `<top (required)>'
	36: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
	35: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/exe/bundle:49:in `block in <top (required)>'
	34: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/cli.rb:25:in `start'
	33: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	32: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/cli.rb:31:in `dispatch'
	31: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	30: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	29: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	28: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/cli.rb:477:in `exec'
	27: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:23:in `run'
	26: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:58:in `kernel_load'
	25: from /Users/adriculous/.gem/ruby/2.6.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:58:in `load'
	24: from /Users/adriculous/.gem/ruby/2.6.0/bin/jekyll:23:in `<top (required)>'
	23: from /Users/adriculous/.gem/ruby/2.6.0/bin/jekyll:23:in `load'
	22: from /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
	21: from /Users/adriculous/.gem/ruby/2.6.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
	20: from /Users/adriculous/.gem/ruby/2.6.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	19: from /Users/adriculous/.gem/ruby/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	18: from /Users/adriculous/.gem/ruby/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	17: from /Users/adriculous/.gem/ruby/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	16: from /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
	15: from /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
	14: from /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
	13: from /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
	12: from /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:102:in `process'
	11: from /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:215:in `start_up_webrick'
	10: from /Library/Ruby/Gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:215:in `new'
	 9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/webrick/httpserver.rb:47:in `initialize'
	 8: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/webrick/server.rb:108:in `initialize'
	 7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/webrick/server.rb:127:in `listen'
	 6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/webrick/utils.rb:65:in `create_listeners'
	 5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/socket.rb:762:in `tcp_server_sockets'
	 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/socket.rb:227:in `foreach'
	 3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/socket.rb:227:in `each'
	 2: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/socket.rb:764:in `block in tcp_server_sockets'
	 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/socket.rb:201:in `listen'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/socket.rb:201:in `bind': Address already in use - bind(2) for 127.0.0.1:4000 (Errno::EADDRINUSE)

The ones that stood out for me from that error are bundler: failed to load command: jekyll (/Users/adriculous/.gem/ruby/2.6.0/bin/jekyll) and the last line: 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/socket.rb:201:in listen’
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/socket.rb:201:in bind': Address already in use - bind(2) for 127.0.0.1:4000 (Errno::EADDRINUSE)

I don’t know how to fix these errors, so I decided to ask everyone here to guide me through these steps. Any suggestions on how I can fix this?

I’m using macOS (Big Sur) as my OS.

Thank you!

it looks like you have ruby installed in 2 places and it is confused. If you look at the output sometimes it is in /Library and other times it is in /System.

How did you install ruby? what OS?

Try uninstalling ruby and re-installing it.

How did you install ruby? what OS?

As I mentioned at the bottom of my original post, I’m using macOS (Big Sur). I read that it was already installed in my system, so I didn’t directly install ruby then. I also read that I shouldn’t use the ruby that’s already pre-installed in the system, so I installed ruby on another path.

I went ahead and installed ruby via Homebrew. I even changed the $PATH so that the system would read the ruby installed on that particular path. When I typed which -a ruby, it’s now installed in these two paths:

/usr/local/opt/ruby/bin/ruby
/usr/bin/ruby

When I entered which ruby in my Terminal, /usr/local/opt/ruby/bin/ruby came out as a result, so I thought that should fix it. I uninstalled and re-installed Jekyll and followed along the instructions and recreated a new project folder.

Once again, I want to view the newly-built site with bundle exec jekyll serve. It still didn’t work and gave me these errors:

Configuration file: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adriannedev/_config.yml
            Source: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adriannedev
       Destination: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adriannedev/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
                    done in 3.422 seconds.
 Auto-regeneration: enabled for '/Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adriannedev'
                    ------------------------------------------------
      Jekyll 4.2.0   Please append `--trace` to the `serve` command
                     for any additional information or backtrace.
                    ------------------------------------------------
/usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve/servlet.rb:3:in `require': cannot load such file -- webrick (LoadError)
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve/servlet.rb:3:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:179:in `require_relative'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:179:in `setup'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:100:in `process'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `<top (required)>'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli.rb:477:in `exec'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli.rb:31:in `dispatch'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli.rb:25:in `start'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/exe/bundle:49:in `block in <top (required)>'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/exe/bundle:37:in `<top (required)>'
	from /usr/local/opt/ruby/bin/bundle:23:in `load'
	from /usr/local/opt/ruby/bin/bundle:23:in `<main>'

I don’t know what’s going on anymore. Please advise?

Thank you!

progress I think, now it looks like you are using ruby 3 which isn’t quite supported yet? though I think you just need to manually install webrick?

there are a few threads in here about what you need to use ruby 3, it wasn’t much.

I tried to add webrick gem install webrick. Then I attempted to run bundle exec jekyll serve again, then gave me the following result:

Configuration file: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adriannedev/_config.yml
            Source: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adriannedev
       Destination: /Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adriannedev/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
                    done in 0.72 seconds.
 Auto-regeneration: enabled for '/Users/adriculous/Dropbox/Udemy/Jekyll and Hugo/adriannedev'
                    ------------------------------------------------
      Jekyll 4.2.0   Please append `--trace` to the `serve` command
                     for any additional information or backtrace.
                    ------------------------------------------------
/usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/socket.rb:201:in `bind': Address already in use - bind(2) for 127.0.0.1:4000 (Errno::EADDRINUSE)
	from /usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/socket.rb:201:in `listen'
	from /usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/socket.rb:765:in `block in tcp_server_sockets'
	from /usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/socket.rb:227:in `each'
	from /usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/socket.rb:227:in `foreach'
	from /usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/socket.rb:763:in `tcp_server_sockets'
	from /usr/local/lib/ruby/gems/3.0.0/gems/webrick-1.7.0/lib/webrick/utils.rb:60:in `create_listeners'
	from /usr/local/lib/ruby/gems/3.0.0/gems/webrick-1.7.0/lib/webrick/server.rb:130:in `listen'
	from /usr/local/lib/ruby/gems/3.0.0/gems/webrick-1.7.0/lib/webrick/server.rb:111:in `initialize'
	from /usr/local/lib/ruby/gems/3.0.0/gems/webrick-1.7.0/lib/webrick/httpserver.rb:47:in `initialize'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:215:in `new'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:215:in `start_up_webrick'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:102:in `process'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	from /usr/local/lib/ruby/gems/3.0.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `<top (required)>'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli.rb:477:in `exec'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli.rb:31:in `dispatch'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/cli.rb:25:in `start'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/exe/bundle:49:in `block in <top (required)>'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
	from /Users/adriculous/.gem/ruby/3.0.0/gems/bundler-2.2.27/exe/bundle:37:in `<top (required)>'
	from /usr/local/opt/ruby/bin/bundle:23:in `load'
	from /usr/local/opt/ruby/bin/bundle:23:in `<main>'

I don’t understand what this means or what error it’s giving me now: /usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/socket.rb:201:in bind’: Address already in use - bind(2) for 127.0.0.1:4000 (Errno::EADDRINUSE)`

I’m also looking into another static site generator in case Jekyll wouldn’t work for me, but I’m determined to make it work.

Please help, thank you.

if you paste that address in the browser is there something there? sounds like it is saying port 4000 is in use already.

Here is another thread that may help:

Indeed another instance of Jekyll is likely running. I’ve never seen other tools using port 4000

Of course just visit that address on 4000 and it will show you a page anyway and you can see what was already running

hello
i have the same problem , and excatly same erro : Generating…
Jekyll Feed: Generating feed for posts
Liquid Exception: undefined method `untaint’ for “Welcome to Jekyll!”:String in C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/minima-2.5.1/_layouts/post.html

but i’m using windows 11 ,
i have: ruby 3.2.0
gem 3.4.1
jeklly 4.3.1

i exactly installed ruby twice , but then i uninstalled one version

how can i fix the bug , it’s first time that i try to do : bundle exec jekyll serve

will be very happy if someone can help me :slight_smile:

Can you add this gem "webrick" in your gemfile and try again

looks like a ruby version issue?

Hello, I also had this issue and looked into it this is what I found to work for me.

Note: I am running this environment
gem -v
3.4.3

ruby -v
ruby 3.2.0 (2022-12-25 revision a528908271) [x64-mingw-ucrt]

Windows 11
Git


I found this link here on the official jekyll github page: Issue with ref to solution

The last comment mentions they pushed a patch and you have to edit your “Gemfile” file, you will have to comment out

gem “jekyll”, “~> 4.3.1”

And replace with

gem “jekyll”, github: “jekyll/jekyll”, ref: “refs/pull/9248/head”

Then you should be able to successfully run

bundle exec jekyll serve

Hopefully this helps.