Menu
Coddy logo textTech

Reading a Failure

Lesson 46 of 47 in Coddy's Networking with the Terminal course.

Put the whole course together into one method. When something will not connect, you are choosing between a small number of causes, and each has a distinctive signature.

  • The name did not resolve. It fails fast, before any connection. Check with a lookup.
  • Nothing is listening. Refused immediately, curl exit 7.
  • Traffic is being dropped. It hangs, then exit 28.
  • The port does not speak TLS. Exit 35.
  • It connected fine. Now read the status code: 4xx is your request, 5xx is theirs.

Two of those are distinguished by how long the failure takes, which is why noticing whether something failed instantly or hung is worth more than any error message.

Work from the bottom of the stack up: name, then machine, then port, then service, then response.

challenge icon

Challenge

Expert

Produce three different failures and label each by its exit code.

With no server running anywhere, print:

  1. refused: and the code from http://127.0.0.1:9999/
  2. dropped: and the code from http://10.255.255.1/ with a 2 second limit
  3. notls: and the code from https://127.0.0.1:9999/

Expected output:

refused: 7
dropped: 28
notls: 7

The third is worth thinking about: with nothing listening at all, the connection is refused before TLS is ever attempted.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Networking with the Terminal

Practice on your own: Terminal playground