Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Websocket for LiveReload using wrong port if Hugo binds to port 80 #2205
Let's say I clone this repo:
Then start up a docker container on Hugo 0.16:
Where I have watch on and I'm listening on port 80. When you load the site, you get:
Which is clearly trying to connect to the hugo server on the wrong port. If you pop the port number up one value:
It works as expected (from chrome console):
Originally discussed and discovered here: https://discuss.gohugo.io/t/live-reload-unconnectable-in-docker-container/3457/4
I like typing less stuff in my url bar? "Because."? Does it matter? Why shouldn't I use port 80? There's a config option for it and in certain situations it causes other functionality to fail.
The port I choose for
In analogy/joke form:
Not helpful, doc.
This piqued my interest, and I decided to try it with Hugo v0.16 (hugo_0.16-1_armhf.deb) running on my Raspberry Pi 3:
(I set my home router resolves
So that answered two questions that I was going to ask @chuyskywalker:
I then ran
That said, I don't think Hugo ever sets LiveReload to listen at 35729 by default. When
So, my suspicion would be on the client-side livereload.js. But let's google first, and lo and behold!
So, it is Google Chrome and Mozilla Firefox's doing. And it is probably relatively recent too, which explains why it used to work for you, but no longer.
Since it is not Hugo's bug, we can choose to:
Probably not too high priority. Any volunteers?
Actually, based on one of your links, livereload can be told what port to use, ala
Seems like it would be sane to inject that into the URL based on the port that Hugo is bound to
@chuyskywalker Good catch! I missed or misunderstood that, and glad that you came up with a fix! It looks good to me at first glance, though I haven't tested it yet.
Care to make a pull request so more experienced Hugo developers can look at it and eventually merge it? See our https://github.com/spf13/hugo/blob/master/CONTRIBUTING.md guide. Many thanks!
@dplesca -- I copied https://github.com/dplesca/hugo/commit/8323f694d54a3605a234e5572138025c4ad72491 into my own repo, compiled, and tried it. Tests pass and live reload works on port 80 afterwards, yay!