Menu
Coddy logo textTech

Status Codes

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

Every response opens with a three digit code, and the first digit tells you who to blame:

  • 2xx worked. 200 OK, 201 Created.
  • 3xx go somewhere else. 301 moved permanently, 302 found.
  • 4xx the request was wrong. 404 not found, 401 unauthorized, 403 forbidden.
  • 5xx the server broke. 500 internal error, 503 unavailable.

The 4xx and 5xx split is the useful one. 4xx is your fault, so fix the request: wrong path, missing token, bad data. 5xx is their fault, so retrying may help and changing your request will not.

Remember that a 404 is a perfectly successful request. The connection worked, the server understood, and its answer was "no such thing". curl exits 0.

challenge icon

Challenge

Medium

Get two different codes out of the same server.

  1. Create index.html containing here and serve the folder on port 9112
  2. Ask for /index.html and print its status code
  3. Ask for /missing.html and print its status code

Expected output:

200
404

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