Linux Labs

Networking / Stage 6 of 14

From connection to application response

Not running Starting usually ~20 s
Leave the lesson

Step 4 of 7 · theory · 5 min

What an answer means

An error answer is still an answer. A script notices the error by the curl exit code, and whether it is the right site — by the text of the answer.

To curl without options, a 503 answer is a successful exchange: there was a connection, an answer arrived, and the code is 0. With the -f (--fail) option it treats a status of 400 or higher as an error: it prints curl: (22) The requested URL returned error: 503 and exits with code 22. Scripts and monitoring need exactly that code.

Once a status arrives, the network and the port are fine: look in the application itself — its configuration, log, dependencies.

A 200 status is not everything either. Another site or a placeholder might have answered at that address. So a check looks at both the status and the answer's text: for the practice service it is the line ports-lab-ok.

Check yourself 1 question

A check from the client printed this line. Where do you look for the cause?

curl: (22) The requested URL returned error: 503
  • The server sent the 503 status, so there was a connection and the request arrived. The network did its part.

  • A filter dropping packets would give a timeout with no answer. Here an answer arrived.

  • -f only turns a status of 400 or higher into code 22. Without it, curl gets the same 503 with code 0.

503 is the application's answer status: there is a connection and the request arrived, but the service is not ready to serve it. The cause is in the application itself.

Key points

  • Without -f, curl exits with code 0 even on a 503 answer; with -f, with code 22.
  • A status in the answer means the network and the port are fine, and the error is in the application.
  • A service check looks at the status and the answer's text.
Ubuntu 24.04
Loading…