HTTP Status Codes: A Practical Guide for Developers and SEO
7 min read · Published 1 November 2026 · Updated 2 November 2026
Every HTTP response starts with a three-digit status code that tells the client what happened. Choosing the right code makes APIs predictable, helps you debug problems in seconds and, for websites, tells search engines how to treat a page. This guide covers the codes you will meet most often and how to use them well.
In this guide
The five classes
- 1xx informational: the request was received and processing continues (rare in everyday work).
- 2xx success: the request worked.
- 3xx redirection: the client should look somewhere else.
- 4xx client error: the request is wrong or not allowed. The client should change something before retrying.
- 5xx server error: the request was fine but the server failed. A retry later may succeed.
Success codes (2xx)
- 200 OK: the standard success response, with a body.
- 201 Created: a new resource was created. Return its address in the Location header.
- 202 Accepted: the request was accepted but is processed later (for example a background job).
- 204 No Content: success with no body, common for DELETE and some updates.
Redirects (3xx)
- 301 Moved Permanently: the resource has a new permanent address. Search engines transfer ranking signals to the new URL.
- 302 Found and 307 Temporary Redirect: a temporary move. Use these when the original address will be used again.
- 308 Permanent Redirect: like 301, but it guarantees that the HTTP method (such as POST) is preserved.
- 304 Not Modified: the cached copy is still valid, so the server sends no body. It saves bandwidth when used with ETag or Last-Modified.
Client errors (4xx)
- 400 Bad Request: malformed syntax or invalid data. Explain what is wrong in the response body.
- 401 Unauthorized: despite the name, it means "not authenticated": credentials are missing or invalid.
- 403 Forbidden: the client is authenticated, but is not allowed to do this.
- 404 Not Found: no such resource. Also used to avoid revealing that a protected resource exists.
- 405 Method Not Allowed: the resource exists but not for this HTTP method (for example POST to a read-only endpoint). Send an Allow header.
- 409 Conflict: the request conflicts with the current state, such as a duplicate or an edit conflict.
- 410 Gone: the resource used to exist and was removed on purpose.
- 422 Unprocessable Content: the syntax is valid but the content fails validation rules.
- 429 Too Many Requests: rate limit reached. Add a Retry-After header.
Server errors (5xx)
- 500 Internal Server Error: an unexpected failure on the server. Log details privately and return a generic message.
- 502 Bad Gateway: a gateway or proxy received an invalid response from the server behind it.
- 503 Service Unavailable: the server is overloaded or down for maintenance. Add Retry-After if you know when it will be back.
- 504 Gateway Timeout: a gateway did not get a response from the server behind it in time.
Designing an API with status codes
- Use the code that matches the outcome. Do not return 200 with an error message inside the body, because clients and monitoring tools rely on the status.
- Return a consistent JSON error body with a stable machine-readable code and a human-readable message.
- Distinguish 401 (who are you?) from 403 (you may not do that).
- Use 404 for a missing resource and 400 or 422 for bad input, so clients can tell them apart.
- Document which codes each endpoint can return.
Example error body
HTTP/1.1 422 Unprocessable Content
Content-Type: application/json
{
"error": "validation_failed",
"message": "email must be a valid address",
"field": "email"
}Why it matters for search engines
- Use 301 or 308 when a page moves permanently, so ranking signals follow it. A long chain of redirects wastes crawl time.
- A page that no longer exists should return 404 or 410. Returning 200 with a "not found" message creates a soft 404, which confuses crawlers.
- For planned downtime, return 503 with Retry-After, so search engines know the outage is temporary and do not drop your pages.
- Frequent 5xx errors can make crawlers visit less often.
Debugging tips
The browser developer tools (Network tab) show the status of each request. From a terminal, curl -I https://example.com prints only the headers, including the status line. When a response has a JSON body, paste it into a formatter to read the error structure at a glance.
Frequently asked questions
- What is the difference between 401 and 403?
- 401 means the client is not authenticated: log in or send valid credentials. 403 means the server knows who you are, but you do not have permission.
- Should I use 301 or 308?
- Both are permanent. 308 guarantees that the original method and body are reused, while 301 historically allows clients to change a POST into a GET. For ordinary page moves, 301 is fine.
- What is the difference between 404 and 410?
- 404 says the resource was not found, without saying why. 410 says it is gone permanently on purpose. Both lead search engines to drop the page, 410 sometimes a little faster.
- Does a 5xx error hurt SEO?
- A short outage does not usually harm a site, especially with a 503 and Retry-After. Persistent errors can cause crawlers to visit less often and pages to drop out of the index.
Sources and further reading
Try it yourself: JSON Formatter & Validator runs in your browser, free and with no sign-up.