Can't access Hugo @ localhost

I’m using a Raspberry Pi v2 running Jessie, and have installed Hugo following the ‘Quickstart guide’ ‘Bookshelf’ example, and everything appeared to go well down to Step 5, but at no stage have I managed to access the webpage at http://localhost:1313, I just get ‘Unable to connect’.

From the SSH I see;

Started building site
1 of 1 draft rendered
0 future content
1 pages created
0 non-page files copied
2 paginator pages created
0 tags created
0 categories created
in 194 ms
Watching for changes in /home/pi/hugo_working_dir/bookshelf/{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)```

The things I've tried;
- 192.168.1.10 displays my current html website OK
- 192.168.1.10:8443 displays my node-red admin page OK
- Tried 127.0.0.1:1313/ & 192.168.1.10:1313/ - 'Unable to connect'
- Opening port 1313 in my router - 'Unable to connect'
- Tried running ``` $ netstat -4 -tln``` and get:
```active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:1313          0.0.0.0:*               LISTEN
(plus the other connections)```

Any help would be appreciated.

Paul

Can you access the address via curl or wget from the server itself?

I assume you mean SSH into the raspberry pi and;

$ wget http://localhost:1313

Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:1313... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:1313... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3756 (3.7K) [text/html]
Saving to: index.html

index.html          100%[=====================>]   3.67K  --.-KB/s   in 0s

2016-08-07 23:26:06 (60.3 MB/s) - ‘index.html’ saved [3756/3756]

So because I can wget the index.html file, this presumably means that Hugo has generated the page, yet I still can’t view it at localhost:1313 (discourse won’t let me enter the full url!!)
A further check of my hosts file shows;

$ sudo nano /etc/hosts

::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
127.0.1.1       raspberrypi```

Running wget on the same host should work fine. Your problem is that Hugo’s server can’t be accessed outside of your Raspberry Pi. Give the following command a try:

hugo server --bind "0.0.0.0"
1 Like

If I try hugo server --bind “0.0.0.0”

Started building site
=============================================================
Your rendered home page is blank: /index.html is zero-length
 * Did you specify a theme on the command-line or in your
   "config.toml" file?  (Current theme: "")
 * For more debugging information, run "hugo -v"
=============================================================
0 of 1 draft rendered
etc...```

If I try;

``` $ hugo server --theme=hugo_theme_robust --buildDrafts --bind "0.0.0.0"```

that takes me a bit further, and I can access the site at my Raspberry Pi's IP - 192.168.1.10:1313 (not by localhost:1313), but the theme is missing.

<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/standard10/uploads/gohugo/original/2X/9/966e4a3a328ec901e14e364aabefc7d9586b9dda.png" width="690" height="185">

Try:

hugo server --theme=hugo_theme_robust --buildDrafts --bind "0.0.0.0" --baseURL 192.168.1.10:1313

As to localhost vs the rest I suggest you read a little about IP addresses and network interfaces; this isn’t Hugo specific.

1 Like

Thanks, yes that works!
I’m happy using 192.168.1.10:1313 and adding --bind & --baseURL to build the draft, but will this create me problems further down the road?

No it will not. At some point you might get a domain: Just switch the baseURL.

That’s good to hear Bjørn, I already have a domain and existing blog based on Markdown, but was blown away with Hugo.
I’m not as competent as perhaps other forum members, but I’m slowly getting there… :wink:

Paul