I am remotely (via SSH) working on my artix web server where I am updating my website with hugo (https://gohugo.io) (static webpage generator). To preview the freshly updated website, hugo software runs a temporary webserver for test purposes at localhost:1313
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Then I try to access this preview from the remote client in a regular web-browser. I replace the `localhost` with the artix server's local IP address, e.g.
192.168.2.135:1313, but always get a
ERR_CONNECTION_REFUSED. I have checked that I am not blocking port 1313 in iptables and that iptables is running:
# Generated by iptables-save v1.8.4 on Sun Jul 12 10:32:23 2020
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [57:7468]
:TCP - [0:0]
:UDP - [0:0]
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate INVALID -j DROP
-A INPUT -p icmp -m icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -p udp -m conntrack --ctstate NEW -j UDP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j TCP
-A INPUT -p udp -j REJECT --reject-with icmp-port-unreachable
-A INPUT -p tcp -j REJECT --reject-with tcp-reset
-A INPUT -j REJECT --reject-with icmp-proto-unreachable
-A TCP -p tcp -m tcp --dport 35145 -j ACCEPT
-A TCP -p tcp -m tcp --dport 80 -j ACCEPT
-A TCP -p tcp -m tcp --dport 443 -j ACCEPT
-A TCP -p tcp -m tcp --dport 53 -j ACCEPT
-A TCP -p tcp -m tcp --dport 1313 -j ACCEPT
-A UDP -p udp -m udp --dport 53 -j ACCEPT
COMMIT
# Completed on Sun Jul 12 10:32:23 2020
Chain INPUT (policy DROP 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 654 530K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
2 18 1080 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
3 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
4 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmptype 8 ctstate NEW
5 14 4817 UDP udp -- * * 0.0.0.0/0 0.0.0.0/0 ctstate NEW
6 30 1560 TCP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x17/0x02 ctstate NEW
7 14 4817 REJECT udp -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
8 0 0 REJECT tcp -- * * 0.0.0.0/0 0.0.0.0/0 reject-with tcp-reset
9 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-proto-unreachable
Chain FORWARD (policy DROP 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 655 packets, 154K bytes)
num pkts bytes target prot opt in out source destination
Chain TCP (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:35145
2 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
3 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
4 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
5 30 1560 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:1313
Chain UDP (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:53
Locally, i.e. on the artix web server itself, the web page preview can be viewed. I can also view it in the text-based browser elinks inside the ssh session on my remote client.
The regular apache webserver run on the system server shows webpages allright, I can see them from any client (http://192.168.2.135:80). Just why can't I remotely access the hugo test server?
Hi. Maybe the server is listening only in 127.0.0.1 (Localhost) and you cannot access from other site different than server machine.
Could you execute this please?
ss -putan | grep 1313
If the server is listening only in localhost you might have to change the configuration file.
Edit: I don't knowhow you are starting the hugo service but you can try this:
hugo server --bind=192.168.2.135
Then the service will be available from any place on your network.
$ss -putan | grep 80
tcp LISTEN 0 511 *:80 *:*
I also checked port 1313 this way:
$ss -putan | grep 1313
tcp LISTEN 0 4096 127.0.0.1:1313 0.0.0.0:* users:(("hugo",pid=17232,fd=14))
tcp ESTAB 0 0 127.0.0.1:1313 127.0.0.1:34998 users:(("hugo",pid=17232,fd=15))
tcp ESTAB 0 0 127.0.0.1:34998 127.0.0.1:1313 users:(("chromium",pid=1783,fd=23))
What does this all tell us?
It tells me what I suspect. The Hugo server in only listening in localhost. That's mean you can only access from your own machine.
To solve the problem you have to start the Hugo server like I said
hugo server --bind=192.168.2.135
Or you have to edit the corresponding configuration file to bind from an IP different to localhost (127.0.0.1).
I don't know anything about Hugo but there should be a configuration file for server)
You're absolutely right. I started only "hugo server" with all defaults. When I did it like you suggested, it works. Thank you very much for your quick response.