DEV Community

👨‍💻Ioannis Diamantidis
👨‍💻Ioannis Diamantidis

Posted on • Originally published at diamantidis.github.io

1

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!! 🚀

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay