Fix
Connection refused vs connection timed out
Refused: a machine answered with a reset, so nothing listens there or a firewall rejects it. Timed out: nothing answered, so packets are dropped or lost.
Likely causes
- Refused: the service is not running, listens on another address or port, or a firewall rule says
REJECT --reject-with tcp-reset. - Timed out: a firewall rule says
DROP, a route is missing, or the host is down.
Diagnose
Run these in order. The output is what each printed on a lab's real Linux machines.
-
till:~# curl -sv http://10.0.1.12:7000 - Nothing listens on 10.0.1.12:7000: the server's kernel answers the SYN with a reset, at once.
* 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
-
patron:~# curl -sS -m 3 http://10.40.2.10:8080/ - A firewall drops port 8080: no answer, so curl waits its 3 seconds and gives up.
curl: (28) Connection timed out after 3007 milliseconds
-
patron:~# nmap -n -Pn -p 8000,8080 10.40.2.10 - nmap calls the dropped port
filtered, and the empty port beside itclosed.Starting Nmap 7.95 ( https://nmap.org ) at 2026-11-02 08:25 UTC Nmap scan report for 10.40.2.10 Host is up (0.000091s latency). PORT STATE SERVICE 8000/tcp closed http-alt 8080/tcp filtered http-proxy Nmap done: 1 IP address (1 host up) scanned in 1.46 seconds
-
patron:~# curl -sS -m 3 http://10.40.2.10:8080/ - The firewall now rejects with a reset: curl fails at once, exactly like a closed port.
curl: (7) Failed to connect to 10.40.2.10 port 8080 after 0 ms: Could not connect to server
-
patron:~# nmap -n -Pn -p 8000,8080 10.40.2.10 - A rejected port and a really empty one look the same:
closed.Starting Nmap 7.95 ( https://nmap.org ) at 2026-11-02 08:25 UTC Nmap scan report for 10.40.2.10 Host is up (0.000054s latency). PORT STATE SERVICE 8000/tcp closed http-alt 8080/tcp closed http-proxy Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
Fix
-
iptables -D FORWARD 1 - For a timeout your firewall causes: find the
DROPwhose counter climbs with each try, and delete it by its line number. -
stageDoor:~# iptables -v -I FORWARD 1 -s 10.40.1.0/24 -p tcp --dport 8080 -j ACCEPT - Or, to let only some machines through, insert an exception above the rule that stops them: the first rule that fits decides.
ACCEPT tcp opt -- in * out * 10.40.1.0/24 -> 0.0.0.0/0 tcp dpt:8080
-
boxOffice:~# curl -sS -m 3 http://10.40.2.10:8080/ - The staff's request now meets the exception first, and the till loads.
Till: 214 seats sold tonight. Takings 6,420. Refunds at /refund
Break it and fix it yourself
Each lab is a small network of real Linux machines in your browser, where this fault happens.
- Ports and sockets: one address, many programs : its challenge "The order page fails on the till" set the fault for you to find and fix.
- Firewall rules: keep the street out and let the staff in : its challenge "Nobody on the street can buy a ticket" set the fault for you to find and fix.