1. The purpose of this post

I would demo how do I get jekyll website to run on a port other than 4000?

2. Environments

  • jekyll 2.x and 3.x

3. The default start command

The default way we start jekyll website is as follows:

bundle exec jekyll serve --detach

we would get this response:

    Server address: http://127.0.0.1:4000/

4. Specify the port of jekyll website

According to the jekyll official configuration document, we can start the jekyll website with the –port option like this:

If we want to run jekyll website on port 8080, we can run command like this:

bundle exec jekyll serve --port 8080 --detach

Then we get:

    Server address: http://127.0.0.1:8080/

5. Specify the host and port of the jekyll website

If you don’t want to run on localhost(127.0.0.1), you can also specify the host by command options like this:

bundle exec jekyll serve --host 198.18.58.2 --port 8080 --detach

Then we get:

    Server address: http://198.18.58.2:8080/

Then you can visit your site from anywhere.

6. Conclusion

You can use –host and –port to run jekyll website on different host and port, if you want to use more options, just reference the offical document of jekyll.