Understanding HTTP Status Codes: A Complete Reference for Web Developers
HTTP status codes are the three-digit numbers that web servers send in response to every request. They tell the browser — and the developer — whether a request succeeded, failed, or needs further action. Understanding these codes is essential for debugging websites, configuring servers, and managing migrations. This guide covers every status code you are likely to encounter, organised by category.
How Status Codes Work
Every HTTP response includes a status code in its first line. The code consists of three digits, and the first digit defines the category:
- 1xx — Informational: The request was received and is being processed
- 2xx — Success: The request was successfully received, understood, and accepted
- 3xx — Redirection: Further action is needed to complete the request
- 4xx — Client Error: The request contains an error or cannot be fulfilled
- 5xx — Server Error: The server failed to fulfill a valid request
2xx Success Codes
200 OK
The most common status code. The request succeeded and the server is returning the requested content. When you load a webpage and everything works, the server returned a 200.
201 Created
The request succeeded and a new resource was created. Commonly returned after a successful POST request — for example, when submitting a form that creates a new record in a database.
204 No Content
The request succeeded but there is no content to return. Often used for DELETE requests or form submissions where no response body is needed.
3xx Redirection Codes
301 Moved Permanently
The requested resource has been permanently moved to a new URL. Browsers and search engines should use the new URL for all future requests. This is the most important redirect for SEO — it transfers ranking signals from the old URL to the new one. Use 301 redirects when restructuring URLs, changing domains, or migrating from HTTP to HTTPS.
302 Found (Temporary Redirect)
The resource is temporarily available at a different URL, but the original URL should continue to be used for future requests. Search engines do not transfer ranking signals with 302 redirects. Use them for temporary situations — like redirecting users to a maintenance page during updates.
304 Not Modified
The resource has not changed since the browser last requested it. The server tells the browser to use its cached copy. This saves bandwidth and improves performance — the browser does not need to download the full resource again.
307 Temporary Redirect
Similar to 302, but guarantees that the HTTP method (GET, POST) will not change during the redirect. If the original request was a POST, the redirected request will also be a POST.
308 Permanent Redirect
Similar to 301, but guarantees the HTTP method will not change. This is the technically correct redirect for permanently moving resources that receive POST requests.
4xx Client Error Codes
400 Bad Request
The server cannot process the request because of a client error — malformed syntax, invalid parameters, or a request that does not make sense. This often indicates a problem with the URL, request headers, or submitted data.
401 Unauthorized
The request requires authentication. The client must provide valid credentials (usually a username and password) to access the resource. Despite the name, this code is about authentication (who you are), not authorisation (what you can do).
403 Forbidden
The server understood the request but refuses to authorise it. Unlike 401, providing credentials will not help — the server has decided you are not allowed to access this resource. Common causes include incorrect file permissions, IP-based access restrictions, or directory listing being disabled.
404 Not Found
The most well-known error code. The server cannot find the requested resource. This usually means the URL is wrong, the page has been deleted, or the permalink structure has changed. During migrations, 404 errors often appear when URL rewrite rules (like .htaccess) are not properly configured on the new server.
405 Method Not Allowed
The HTTP method used (GET, POST, PUT, DELETE) is not allowed for the requested resource. For example, trying to POST to a URL that only accepts GET requests.
408 Request Timeout
The server timed out waiting for the client to send a complete request. This can happen with slow connections or when uploading large files.
429 Too Many Requests
The client has sent too many requests in a given time period. This is used for rate limiting to prevent abuse. If you see this code, you need to slow down your requests.
5xx Server Error Codes
500 Internal Server Error
The most generic server error. Something went wrong on the server, but the server cannot be more specific about what. Common causes include PHP errors, misconfigured .htaccess files, exhausted memory limits, and database connection failures. Check your server error logs for details.
502 Bad Gateway
The server, acting as a gateway or proxy, received an invalid response from an upstream server. Common with reverse proxies (like Nginx proxying to PHP-FPM or Apache) when the backend server crashes or does not respond correctly.
503 Service Unavailable
The server is temporarily unable to handle the request, usually because it is overloaded or undergoing maintenance. Unlike 500, this implies the situation is temporary. Many websites display custom 503 pages during planned maintenance.
504 Gateway Timeout
The server, acting as a gateway or proxy, did not receive a timely response from the upstream server. This often indicates that a backend process (like a database query or API call) is taking too long.
Status Codes and Server Migrations
During server migrations, certain status codes appear more frequently:
- 404 errors when URL rewrite rules are not configured on the new server
- 500 errors from PHP version incompatibilities or missing extensions
- 502/504 errors when the web server cannot communicate with PHP or the database
- 403 errors from incorrect file permissions on the new server
Use HostCheck to preview your site on the new server and catch these errors before switching DNS. If you see any error codes in the preview, fix them on the new server while the live site continues running normally.
Conclusion
HTTP status codes are the language servers use to communicate the result of every request. Understanding them helps you debug issues faster, configure redirects correctly, and ensure smooth server migrations. Pay particular attention to 301 redirects for SEO, 404 errors for broken links, and 500 errors for server-side problems. With this knowledge and a preview tool like HostCheck, you can identify and resolve issues before they affect your visitors.