Can't connect to Localhost:4000

Hello all, I’m not to Jekyll and have successfully installed it on my Mac. When I run bundle exec jekyll build it works except I’m not able to see the site. I get a can’t connect to server.

My Gemfile is

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# gem "rails"
gem "jekyll"

and bundle update

Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using public_suffix 4.0.6
Using bundler 2.2.17
Using eventmachine 1.2.7
Using concurrent-ruby 1.1.8
Using colorator 1.1.0
Using http_parser.rb 0.6.0
Using rexml 3.2.5
Using ffi 1.15.0
Using mercenary 0.4.0
Using rb-fsevent 0.10.4
Using safe_yaml 1.0.5
Using unicode-display_width 1.7.0
Using addressable 2.7.0
Using forwardable-extended 2.6.0
Using i18n 1.8.10
Using em-websocket 0.5.2
Using rb-inotify 0.10.1
Using rouge 3.26.0
Using terminal-table 2.0.0
Using liquid 4.0.3
Using listen 3.5.1
Using sassc 2.4.0
Using kramdown 2.3.1
Using pathutil 0.16.2
Using kramdown-parser-gfm 1.1.0
Using jekyll-watch 2.2.1
Using jekyll-sass-converter 2.1.0
Using jekyll 4.2.0
Bundle updated!

Any help greatly appreciated.

Can you provide the restore from your bundle exec Jekyll build?

Hi Bill, I’m new to this. Where do I find it?

This is what shows when I run bundle exec jekyll serve

Configuration file: none
            Source: /Users/Phil/Sites/jekyll-blog
       Destination: /Users/Phil/Sites/jekyll-blog/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 0.043 seconds.
 Auto-regeneration: enabled for '/Users/Phil/Sites/jekyll-blog'
                    ------------------------------------------------
      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 /Users/Phil/.gem/ruby/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	from /Users/Phil/.gem/ruby/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	from /Users/Phil/.gem/ruby/3.0.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	from /Users/Phil/.gem/ruby/3.0.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	from /Users/Phil/.gem/ruby/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/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:63:in `load'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:63:in `kernel_load'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:28:in `run'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/cli.rb:494:in `exec'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/cli.rb:30:in `dispatch'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/cli.rb:24:in `start'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/exe/bundle:49:in `block in <top (required)>'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
	from /Users/Phil/.gem/ruby/3.0.0/gems/bundler-2.2.17/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>'

You need to resolve this issue:

/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)

When you have an error, search StackOverflow/Google for a solution. This error was encountered in the Jekyll forums.

You can try installing Ruby 2.7 - as 3.0 is still new. Or reinstall global gems. You can try these solutions

Later on the thread

One solution for mac:

bundle add webrick

I’m using Mac and never had to directly install webrick in a project or globally.

You might need to make sure you’ve set up your PATH correctly, so that Ruby and gems can be found properly. Maybe webrick is installed globally but just can’t be found.