# Can't access site on localhost:4000

**URL:** <https://talk.jekyllrb.com/t/cant-access-site-on-localhost-4000/9516>\
**Category:** Help\
**Created:** [November 1, 2024, 1:08pm UTC](https://talk.jekyllrb.com/t/cant-access-site-on-localhost-4000/9516 "2024-11-01T13:08:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![astrosnat](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/astrosnat/32/6125_2.png) [@astrosnat](https://talk.jekyllrb.com/u/astrosnat)\
**Post date:** [November 1, 2024, 1:08pm UTC](https://talk.jekyllrb.com/t/cant-access-site-on-localhost-4000/9516/1 "2024-11-01T13:08:18Z")

</div>

Hi all, new to the forum and to Jekyll.

I am running Jekyll in a Docker container on Ubuntu 22.04 LTS.

Here are my logs:

```auto
fatal: not a git repository (or any parent up to mount point /srv)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /srv)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add logger to your Gemfile or gemspec to silence this warning.
csv was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add csv to your Gemfile or gemspec to silence this warning.
/usr/local/lib/ruby/3.3.0/json/common.rb:3: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add ostruct to your Gemfile or gemspec to silence this warning.
/usr/local/bundle/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb:22: warning: base64 was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add base64 to your Gemfile or gemspec to silence this warning.
/usr/local/bundle/gems/liquid-4.0.4/lib/liquid.rb:72: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add bigdecimal to your Gemfile or gemspec to silence this warning.
Configuration file: /srv/jekyll/_config.yml
  Jekyll Spaceship: 🚀 Jekyll-Spaceship 0.10.2
  Jekyll Spaceship: 🎉 A Jekyll plugin to provide powerful supports.
  Jekyll Spaceship: 👉 https://github.com/jeffreytse/jekyll-spaceship
  Jekyll Spaceship: 🗂 use table-processor
  Jekyll Spaceship: 🗂 use mathjax-processor
  Jekyll Spaceship: 🗂 use plantuml-processor
  Jekyll Spaceship: 🗂 use mermaid-processor
  Jekyll Spaceship: 🗂 use polyfill-processor
  Jekyll Spaceship: 🗂 use media-processor
  Jekyll Spaceship: 🗂 use emoji-processor
  Jekyll Spaceship: 🗂 use element-processor
            Source: /srv/jekyll
       Destination: /srv/jekyll/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
  Jekyll Spaceship: [MathjaxProcessor] _posts/2015-01-01-welcome-to-jekyll.md
  Jekyll Spaceship: [TableProcessor] _posts/2015-02-28-test-markdown.md
  Jekyll Spaceship: [EmojiProcessor] _posts/2015-02-28-test-markdown.md
  Jekyll Spaceship: [PolyfillProcessor] _posts/2016-01-01-another-test-markdown.md
  Jekyll Spaceship: [PlantumlProcessor] _posts/2016-01-01-another-test-markdown.md
  Jekyll Spaceship: [MermaidProcessor] _posts/2016-01-01-another-test-markdown.md
  Jekyll Spaceship: [TableProcessor] _posts/2016-01-01-another-test-markdown.md
  Jekyll Spaceship: [MathjaxProcessor] _posts/2016-01-01-another-test-markdown.md
  Jekyll Spaceship: [MediaProcessor] _posts/2016-01-01-another-test-markdown.md
  Jekyll Spaceship: [EmojiProcessor] _posts/2016-01-01-another-test-markdown.md
  Jekyll Spaceship: [TableProcessor] _posts/2017-05-20-this-post-demonstrates-post-content-styles.md
  Jekyll Spaceship: [TableProcessor] _posts/2017-06-10-quick-mardown-example.md
  Jekyll Spaceship: [MathjaxProcessor] _posts/2017-06-10-quick-mardown-example.md
  Jekyll Spaceship: [PlantumlProcessor] _posts/2017-12-04-plantuml-example.md
  Jekyll Spaceship: [MermaidProcessor] _posts/2017-12-08-mermaid-example.md
  Jekyll Spaceship: [TableProcessor] _posts/2017-12-15-table-example.md
  Jekyll Spaceship: [MathjaxProcessor] _posts/2017-12-15-table-example.md
  Jekyll Spaceship: [MediaProcessor] _posts/2017-12-18-video-example.md
  Jekyll Spaceship: [EmojiProcessor] about.html
  Jekyll Spaceship: [MathjaxProcessor] index.html
                    done in 1.32 seconds.
 Auto-regeneration: enabled for '/srv/jekyll'
    Server address: http://0.0.0.0:4000/
  Server running... press ctrl-c to stop.

```

Accessing localhost:4000 in Firefox tells me that my browser cannot establish a connection.

Typing in `sudo lsof -i :4000` doesn’t bring up anything else on that port.

I can find the IP address of my container, and putting in :4000 gives me an error that my request has timed out.

I can grab the contents of an HTML file and display them in the terminal, so something can see them, it’s just not serving them.

---

<div class="post-metadata">

**Author:** ![chuckhoupt](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/chuckhoupt/32/523_2.png) [@chuckhoupt](https://talk.jekyllrb.com/u/chuckhoupt)\
**Post date:** [November 1, 2024, 7:31pm UTC](https://talk.jekyllrb.com/t/cant-access-site-on-localhost-4000/9516/2 "2024-11-01T19:31:04Z")

</div>

Could you show the Docker command? In particular the `-p` or `--publish` flag, which would control how container ports are exposed.

---

<div class="post-metadata">

**Author:** ![fabiomux](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/fabiomux/32/2656_2.png) [@fabiomux](https://talk.jekyllrb.com/u/fabiomux)\
**Post date:** [November 11, 2024, 3:47pm UTC](https://talk.jekyllrb.com/t/cant-access-site-on-localhost-4000/9516/3 "2024-11-11T15:47:42Z")

</div>

Have you tried to point your browser to _http://container\_ip/_ without the _:4000_ port?

---

<div class="post-metadata">

**Author:** ![astrosnat](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/astrosnat/32/6125_2.png) [@astrosnat](https://talk.jekyllrb.com/u/astrosnat)\
**Post date:** [November 18, 2024, 6:56am UTC](https://talk.jekyllrb.com/t/cant-access-site-on-localhost-4000/9516/4 "2024-11-18T06:56:49Z")

</div>

Thanks for replies, both, sorry for the wait.

docker-compose.yaml looks like this:

```auto
  jekyll:
    container_name: $NAME_jekyll
    build:
      context: .
      dockerfile: jekyll.Dockerfile
    ports:
      - "4000:4000"
    volumes:
      - ./srv:/srv/jekyll
    stdin_open: true
    tty: true
    command: /bin/bash

```

dockerfile looks like this:

```auto

FROM ruby:3.3.5-bookworm

RUN <<EOF
    apt-get update
    apt-get upgrade -y
    apt-get install -y --no-install-recommends \
        nano
    apt-get clean
    rm -rf /var/lib/apt/lists/*
EOF

RUN gem install jekyll -v 4.3.4 && gem install bundler

WORKDIR /srv/jekyll

EXPOSE 4000

```

and to run it all I use a script that does this:

```auto

docker compose build --no-cache jekyll
docker compose run jekyll bash

```

---

<div class="post-metadata">

**Author:** ![chuckhoupt](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/chuckhoupt/32/523_2.png) [@chuckhoupt](https://talk.jekyllrb.com/u/chuckhoupt)\
**Post date:** [November 18, 2024, 4:13pm UTC](https://talk.jekyllrb.com/t/cant-access-site-on-localhost-4000/9516/5 "2024-11-18T16:13:18Z")

</div>

By default the [`docker compose run` command does not setup the networking](https://docs.docker.com/reference/cli/docker/compose/run/), so you’d need to add `--service-ports`. For example (tested):

```plaintext
$ docker compose run --service-ports jekyll bash
root@b876583518e4:/srv/jekyll# jekyll serve -H 0.0.0.0

```

---

<div class="post-metadata">

**Author:** ![astrosnat](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/astrosnat/32/6125_2.png) [@astrosnat](https://talk.jekyllrb.com/u/astrosnat)\
**Post date:** [November 20, 2024, 1:33pm UTC](https://talk.jekyllrb.com/t/cant-access-site-on-localhost-4000/9516/6 "2024-11-20T13:33:42Z")

</div>

This fixed it for me. Thank you so much!
