Run Jekyll server on a different port

What to do if the port 4000 is busy and can't run Jekyll?

By: Ajdin Imsirovic 24 March 2023

Jekyll on Ubuntu

It’s very easy to serve a Jekyll blog locally. You just run the following command in the command prompt:

jekyll serve

Even simpler, you can use the short version: jekyll s.

However, if there’s something already serving on port 4000, then you will get an error that might look a bit like this:

jekyll 3.9.2 | Error:  Address already in use - bind(2) for 127.0.0.1:4000
/home/pc/.rbenv/versions/3.1.3/lib/ruby/3.1.0/socket.rb:201:in `bind': Address already in use - bind(2) for 127.0.0.1:4000 (Errno::EADDRINUSE)

To fix this issue, you need to instruct Jekyll to run the blog locally on a different port.

How to run jekyll serve on port 4001?

To run the jekyll serve command on port 4001, you need to specify this port using the following flag:

jekyll serve --port 4001

You can also use the abbreviated command:

jekyll s --port 4001

This means that you can run serveral Jekyll blogs locally at the same time, simply by changing the port number on each Jekyll blog you’re running locally.

Feel free to check out my work here: