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
ExpertProduce three different failures and label each by its exit code.
With no server running anywhere, print:
refused:and the code fromhttp://127.0.0.1:9999/dropped:and the code fromhttp://10.255.255.1/with a 2 second limitnotls:and the code fromhttps://127.0.0.1:9999/
Expected output:
refused: 7
dropped: 28
notls: 7The third is worth thinking about: with nothing listening at all, the connection is refused before TLS is ever attempted.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Networking with the Terminal
6curl in Depth
Seeing the HeadersSaving ResponsesCustom HeadersStatus and Timingcurl Exit CodesRecap: curl Flags9Auth and Debugging
API Keys and BearerThe User AgentTimeouts and RetriesReading a FailureRecap: DebuggingPractice on your own: Terminal playground