DEV Community

👨‍💻Ioannis Diamantidis
👨‍💻Ioannis Diamantidis

Posted on • Originally published at diamantidis.github.io

Jekyll Tip: Use the --host option on your local site to access it from any device on your network

The command jekyll server, by default, binds to 127.0.0.1, as you can see in the following logs.

$ jekyll serve
[...]
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
Enter fullscreen mode Exit fullscreen mode

This means that the website is only accessible by the device that you are running the command.

To make the website accessible by other devices on the same network, run jekyll serve --host=0.0.0.0.

$ jekyll serve --host=0.0.0.0
[...]
Server address: http://0.0.0.0:4000/
Server running... press ctrl-c to stop. 
Enter fullscreen mode Exit fullscreen mode

This will make the Jekyll blog accessible by the IP address of your machine, and thus accessible by other devices on the same network.

A neat command that you can use to find the IP address of your machine is the following:

ifconfig en0 | grep "inet " | awk '{print $2}'
Enter fullscreen mode Exit fullscreen mode

This will output your IP on the Terminal in the format 192.168.0.XXX.

Type this IP followed by :4000 on your favorite browser and you will be able to now browse your blog from the mobile device!! 🚀

Top comments (0)