Hugo 0.14 Ignores --baseUrl Flag --- alternate way to set IP on web server

I’m using Hugo on ubuntu 14.04, I’m giving the server this command line:

hugo server --port=8000 --baseUrl=192.168.59.103

The command is returning this:

0 of 10 drafts rendered
0 future content 
146 pages created
0 paginator pages created
0 tags created
0 categories created
in 534 ms
Serving pages from /docs/public
Web Server is available at http://127.0.0.1:8000

I really need to control the server IP value Hugo’s webserver is using. Is there a way to do this; I know baseURL is being deprecated.

Use --bind=192.168.59.103

Long story, but there was a bug fix in 0.14.

Note that this does not replace BaseURL in any form – they could point to the same IP, but bind is the actually interface the server will bind to.

Thanks @bep that got me a bit further. Now, it is ignoring the port setting:

hugo server --port=8000 --bind=192.168.59.103

Just as a background, I’m running Hugo out of a Docker container. I have to expose port 8000 in the container. This worked fine under Hugo 0.13 with this comman:

hugo server --port=8000 --baseUrl=192.168.59.10

But with the new --bind I’m seeing two things, the port doesn’t get attached to the web server address Hugo is returning. AND, Hugo is complaining about its bind.

hugo server --port=8000 --bind=192.168.59.103
ERROR: 2015/05/26 port 8000 already in use, attempting to use an available port
ERROR: 2015/05/26 Two or more menu items have the same name/identifier in Menu "main": "Locate and run the whalesay image ".
Rename or set an unique identifier.
ERROR: 2015/05/26 MenuEntry's .Url is deprecated and will be removed in Hugo 0.15. Use .URL instead.
0 draft content
0 future content 
9 pages created
0 paginator pages created
0 tags created
0 categories created
in 32 ms
Serving pages from /docs/public
Web Server is available at http://192.168.59.103:48904/
Press Ctrl+C to stop
ERROR: 2015/05/26 Error: listen tcp 192.168.59.103:48904: bind: cannot assign requested address
make: *** [docs] Error 1

Under Hugo .13 no problem:

hugo server --port=8000 --baseUrl=192.168.59.103
ERROR: 2015/05/26 Two or more menu items have the same name/identifier in "main" Menu. Identified as "Locate and run the whalesay image ".
 Rename or set a unique identifier. 
0 draft content 
0 future content 
9 pages created 
0 paginator pages created 
0 tags created
0 categories created
in 34 ms
Serving pages from /docs/public
Web Server is available at http://192.168.59.103:8000/
Press Ctrl+C to stop

Under Docker, I cannot predict the URL that will get assigned, I’m querying the environment to get the IP and setting it in a Makefile to pass to my hugo command line. (I could just use .13 but the images fix Steve did in .14 is something I need for another site I’m building)

My project is here: https://github.com/moxiegirl/getstarted — pretty easy to run if you have Docker installed.

The port override works fine, just tested it.

ERROR: 2015/05/26 port 8000 already in use, attempting to use an available port

Close down the process that has port 8000 open or choose another.

sudo netstat -nlp | grep 8000

Thanks bep — I’ll test again but I ran it several times. I’m curious, did you test it in a Docker container?

No, tested on my Linux laptop. But the error message is pretty clear – and I would be really surprised if this is Docker related.

Thanks for letting me know. Docker gets a bit tricky with ports especially around Mac – where I’m running boot2docker. I expect more than a few of my contributors to run boot2docker and that just messes with both IPs and ports.

If you look at the Dockerfile, you’ll see a dance I’m doing to get the proper IP in a boot2docker environment versus a typical Linux. I’ll have to do some work to debug this further…thanks for your help.

On an added note, looking at the code that fails I notice that it doesn’t log or check the error returned from net.Listen, it just assumes that it is a “port in use” error and tries to find alternative port. But a port conflict is the most likely cause.

And this check has changed ever so slightly in 0.14. In 0.13 it just checked all interfaces on the port, “:1234”, now it checks for the explicit interface (that change can be undone, but I have a problem seeing how that should lead to troubles).

Hi @bep. So, working with one of our release engineers, he was able to isolate this as a Hugo bug.

Definitely a hugo bug, this is running just on a regular ubuntu host. works w/ 0.13, fails with 0.14

```ubuntu@mdougherty-swarm-master-01:~/docs.docker.com$ echo $HUGO_BASE_URL
52.24.78.100
ubuntu@mdougherty-swarm-master-01:~/docs.docker.com$ ./hugo-0.13 server -d ./public --baseUrl=$HUGO_BASE_URL --port=8000
ERROR: 2015/05/26 Unable to locate Config file. Perhaps you need to create a new site. Run `hugo help new` for details
ERROR: 2015/05/26 Unable to find Static Directory: /home/ubuntu/docs.docker.com/static/
0 draft content
0 future content
1 pages created
0 paginator pages created
0 tags created
0 categories created
in 10 ms
Serving pages from /home/ubuntu/docs.docker.com/public
Web Server is available at http://52.24.78.100:8000/
Press Ctrl+C to stop
^C
ubuntu@mdougherty-swarm-master-01:~/docs.docker.com$ ./hugo-0.14 server -d ./public --port=8000 --baseUrl=$HUGO_BASE_URL --bind=$HUGO_BASE_URL
ERROR: 2015/05/26 Unable to locate Config file. Perhaps you need to create a new site. Run `hugo help new` for details
ERROR: 2015/05/26 port 8000 already in use, attempting to use an available port
ERROR: 2015/05/26 Unable to find Static Directory: /home/ubuntu/docs.docker.com/static/
0 draft content
0 future content
1 pages created
0 paginator pages created
0 tags created
0 categories created
in 9 ms
Serving pages from /home/ubuntu/docs.docker.com/public
Web Server is available at http://52.24.78.100:57459/
Press Ctrl+C to stop
ERROR: 2015/05/26 Error: listen tcp 52.24.78.100:57459: bind: cannot assign requested address

Should I file an issue or do you want to confirm first?

Please file an issue, but I’m not sure it is a Hugo issue. You don’t have to be too descriptive, just paste a link to this topic.

Might be a Go issue, or a Docker issue – but that doesn’t really matter. Would be nice if you could point to a Docker image of sort …

Hi Bep,

We took Docker out of the loop to confirm this. Mike was just running on standard EC2 Ubuntu servers.

If you want to see this in an image, the repository I pointed to earlier for my project builds a Docker image. You’ll need to install Docker. Then, just clone the repo and run make docs from the root. My project is here: https://github.com/moxiegirl/getstarted

OK, then there must be an issue with the network interfaces of those Ubuntu EC2 servers. My Ubuntu laptop works fine with this, and it is a pretty standard go method net.Listen that fails in your case.

But I will look into it.

Thanks Bep. Much appreciated.

What you can try first would be to use:

--bind=0.0.0.0

This should emulate the “old” behavior. Looking closer at your error message, I notice that it also fails to bind to the final interface/port combo. So the IP address in bind must be valid/bindable on that host. The failsafe would be 0.0.0.0 => all interfaces.

Hi Bep,

Thanks for this, very much appreciated. This looks like it will work. We are testing across all our environments. I’ll know for sure in the AM.

Cheers,

Moxiegirl