Linux Labs

Networking / Stage 13 of 14

Restore a service from client to answer

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 7 · on a machine · 8 min

A listener on the right address

Connection refused means nobody listens on that address and port. The site may still be running — on another address.

This is the bind address from the listening sockets lesson: listen 127.0.0.1:8080 takes requests from the machine itself, listen 8080 listens on all its addresses. ss -ltn shows which address is actually taken.

In that lesson reload moved the site from 127.0.0.1 to the interface address without stopping it. Here listen gets all addresses at once — see how that goes.

Exercise · look

Reload or restart

The site on lab-node2 listens to itself alone. Fix the listen line in /opt/web-lab/nginx.conf with the first command, apply it with reload, and look at what lab-node2 listens on and what the lab-web log says.

First, predict

The file now says listen 8080, and reload reported no errors. What will ss show?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in

reload reported success, yet the socket stayed the same. nginx could not open 0.0.0.0:8080 next to the taken 127.0.0.1:8080, wrote the error to its log and carried on the old way. An address that does not overlap the old one reload will open — as in the listening sockets lesson — but "all addresses" overlap with any. A restart is the safer way: the old socket closes before the new one opens.

bash
sudo systemctl restart lab-web
sudo ip netns exec lab-node2 ss -ltn
sudo ip netns exec lab-node1 curl -sS -m 3 http://192.0.2.12:8080/

After changing the address, check ss: the exit code of reload says nothing about the address.

Ubuntu 24.04
Loading…