localhost:4000: Jekyll, Phoenix and Apollo
Three popular tools serve on localhost:4000 by default: Jekyll's bundle exec jekyll serve, Elixir's Phoenix framework, and the standalone Apollo GraphQL server. If the page refuses to connect, the build likely failed before the server started. With Jekyll, a baseurl setting can also move the site to a subpath.
| Tool | Start command | Other port |
|---|---|---|
| Jekyll | bundle exec jekyll serve | --port 4001 |
| Phoenix | mix phx.server | PORT=4001 mix phx.server (if config reads PORT) |
| Apollo Server (standalone) | node index.js | listen: { port: 4001 } |
Updated
Port 4000 is popular because it is easy to remember and rarely used by operating systems. That also means conflicts here are almost always two of your own projects running at once.
Serve Jekyll reliably
Install, add webrick, serve
--livereload refreshes the browser when files change.
bundle add webrick
bundle exec jekyll serve --port 4000 --livereload
# from another device on the network
bundle exec jekyll serve --host 0.0.0.0
Static site preview versus a live site
Jekyll's server only previews the generated _site folder; it is not meant to host the site publicly. Deploy the built files to a static host when you are ready.
If writing Markdown and running Ruby is more than you want for a blog, We.Inc can produce a hosted site with a blog from a short description.
How it works
- Run the tool and read the address it prints, such as 'Server address: http://127.0.0.1:4000/'.
- If there is no address, fix the first error above it.
- Free the port if another project holds it.
- Open the exact URL, including any baseurl path.
Tips
- Jekyll with baseurl: /blog in _config.yml serves at localhost:4000/blog/, so the root URL shows a 404.
- Jekyll on Ruby 3 needs gem webrick added to the Gemfile, or serve exits with a load error.
- Phoenix reads the port from config/dev.exs, so changing it there is permanent for the project.
- Apollo Server 4 prints 'Server ready at http://localhost:4000/' only after the schema loads without errors.
Frequently asked questions
What runs on localhost:4000?
Most often Jekyll, Phoenix or Apollo Server, which all choose 4000 by default. Whichever you started last is the one answering.
Why does jekyll serve fail with 'Address already in use'?
Another Jekyll or program holds 4000. Stop it with lsof -i :4000 and kill, or run bundle exec jekyll serve --port 4001.
Why does Jekyll show a 404 at localhost:4000?
Your _config.yml probably sets a baseurl. Open localhost:4000 followed by that path, or leave baseurl empty for local work.
How do I open localhost:4000 from my phone?
Bind to all addresses, for example jekyll serve --host 0.0.0.0, then use your computer's local IP and port 4000 from the phone on the same Wi-Fi.
Related: Static site generators, localhost:3001, GraphQL vs REST, localhost refused to connect.
Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.
More in Guides
- localhost:4200: Fixing the Angular Dev Server
- localhost:47990: Sunshine's Admin Page
- localhost:5000: Flask, .NET and the macOS AirPlay Clash
- localhost:5005: Debugging Java and Running Rasa
- localhost:5173: Fixing the Vite Dev Server Address
- localhost:5678: Running the n8n Editor
- localhost:631: Using the CUPS Web Interface
- bolt://localhost:7687: Neo4j's Driver Connection
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App