Hugo server only serves to host computer?

With most development servers I can use my phone to visit my computer’s IP address and the server’s port (10.0.0.9:1313 for example) and the site will load on my phone. This doesn’t seem to work with the hugo server.

I am currently working on my theme and it would be helpful to preview on an actual phone. Is there any way around this?

EDIT: I changed the title since ‘Hugo server only serves to local machine’ makes it sound like it’s doing exactly what its supposed to. ‘Hugo only serves to host computer’ describes my problem much better.

@Matt_O_Tousa I don’t have time to test right now, but I seem to recall testing this at home on wifi without issue.

That said, if you’re just starting on your theme and don’t have your own build process completely set in stone, I’d recommend looking at Victor Hugo as a sort of starter kit. If nothing else, it has browsersync baked right in…which gives you the accessible server from your phone plus livereload across the multiple devices…

Hi @Matt_O_Tousa, is your phone in the same IP segment as your local machine? When I’m going to publish I always do it, but the has to be able to see the local machine.

Try

hugo server --bind=10.0.0.9

@RickCogley Currently my phone is at 10.0.0.3 and my computer is at 10.0.0.9.

@bep That almost works - my phone will load the HTML but it looks like all the {{ .Site.BaseURL }} tags are still being filled in with localhost, so my CSS and my article links are dead. This is strange, my computer is 10.0.0.9 anyway.

Any other ideas?

Yeah, you need to put a --baseurl=whatever on the command line too.

1 Like

Try:

hugo server --bind=10.0.0.9 --baseURL=http://10.0.0.9:1313
8 Likes

Thanks everybody! That works!

1 Like

it would be awesome if it allowed --bind=0.0.0.0 (all interfaces) on the machine.

Are you saying that does not work?

Actually it works great:
hugo server --bind=0.0.0.0 --baseURL=http://0.0.0.0:1313

Let’s say that I executed the above command from a Virtual Machine that has an IP address of 192.168.1.6

Now when I visit http://192.168.1.6:1313/ on any any device that is connected on my network I get the website that I currently work on served by the Hugo Local Server with instant changes!

This is amazing.

3 Likes

Another cool and slightly related:

 hugo server --liveReloadPort=443 --baseURL=https://yourngrokid.ngrok.io --appendPort=false

Live Reload works great, which is cool and a little bit magic if you’re demoing something for people on the oter side of the world.

7 Likes

Another suggestion, you can also use serveo.net:

ssh -R YOURCHOICE:80:localhost:1313 serveo.net & bg && hugo server --liveReloadPort=443 --baseURL=https://YOURCHOICE.serveo.net --appendPort=false

2 Likes