DEV Developer Toolkit

HTTP Status Codes Reference

Complete reference for all HTTP status codes with meanings, examples, and best practices.

API & Backend

Understanding HTTP Status Codes

HTTP status codes are three-digit numbers returned by a server in response to a client's request. They indicate whether a specific HTTP request has been successfully completed and provide information about the outcome.

Status Code Categories

  • 1xx (Informational): Request received, processing continues
  • 2xx (Success): Request was successful and understood
  • 3xx (Redirection): Further action needed to complete request
  • 4xx (Client Error): Request contains bad syntax or cannot be fulfilled
  • 5xx (Server Error): Server failed to fulfill valid request

Best Practices

  • Return appropriate status codes for each API endpoint response
  • Use 200 for successful GET/POST, 201 for resource creation
  • Use 4xx for client-side errors, 5xx for server-side errors
  • Include meaningful error messages in response body
  • Document which status codes your API can return

FAQs

What is a 404 error?

404 Not Found means the server cannot find the requested resource. Commonly seen when visiting a page that no longer exists or has a typo in the URL.

What does 500 mean?

500 Internal Server Error indicates the server encountered an unexpected condition that prevented it from fulfilling the request. This is a server-side error.

What's the difference between 401 and 403?

401 Unauthorized means authentication is required, while 403 Forbidden means the user is authenticated but doesn't have permission to access the resource.

When should I use 201 vs 200?

Use 201 Created when a new resource is successfully created. Use 200 OK for other successful requests.