Fixes

Fix

Service works on localhost but not from another machine

The service listens on 127.0.0.1 only, so connections to the machine's real address are refused. Make it listen on 0.0.0.0 or on that address.

Likely causes

  1. The program binds to 127.0.0.1 (often a default, or a --host/bind setting).
  2. A firewall on the server or on the path, which shows as a timeout instead of a refusal.

Diagnose

Run these in order. The output is what each printed on a lab's real Linux machines.

backroom:~# nc -w 1 127.0.0.1 7000
On the server itself the service answers.
rye 12
sourdough 4
croissants 30
till:~# curl -sv http://10.0.1.12:7000
From another machine, Connection refused: nothing listens on 10.0.1.12:7000.
*   Trying 10.0.1.12:7000...
* connect to 10.0.1.12 port 7000 from 10.0.1.10 port 38640 failed: Connection refused
* Failed to connect to 10.0.1.12 port 7000 after 0 ms: Could not connect to server
* closing connection #0
backroom:~# ss -tlnp
ss -tlnp shows why: port 7000 listens on 127.0.0.1:7000, while 80 and 8080 listen on 0.0.0.0, every address.
State  Recv-Q Send-Q Local Address:Port  Peer Address:PortProcess                          
LISTEN 0      5          127.0.0.1:7000       0.0.0.0:*    users:(("stockdb",pid=162,fd=5))
LISTEN 0      5            0.0.0.0:8080       0.0.0.0:*    users:(("python3",pid=152,fd=3))
LISTEN 0      4096      127.0.0.11:34969      0.0.0.0:*                                    
LISTEN 0      511          0.0.0.0:80         0.0.0.0:*    users:(("nginx",pid=139,fd=6))  

Fix

sed -i 's/listen 127.0.0.1:80;/listen 80;/' /etc/nginx/http.d/orders.conf restart-orders
Change the listen address, then restart the service (restart-orders is this lab's restart of nginx). For your own program, the same.

The fix the lab's challenge "The order page fails on the till" checks.

Break it and fix it yourself

Each lab is a small network of real Linux machines in your browser, where this fault happens.

Open Ports and sockets: one address, many programs

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab