A developer moves 200 product pages to new URLs with 302 redirects, because 302 is the framework default. Three months later, Google still shows the old URLs in search results. Another site returns 200 OK on its "Page not found" template, and Search Console reports 4,000 soft 404 pages.
An HTTP status code is the three-digit number a server returns with each response. Browsers and Googlebot both read it. Most developers know 200 OK and 404 Not Found. The differences between 301, 302, 307, and 308, between 404, 410, and a soft 404, and between 500 and 503 change how Google crawls and indexes your URLs. This article explains what each code means to Google, when to use it, and how to audit a site for wrong codes.
Know the five code classes
| Class | Meaning | Codes that matter for SEO |
|---|---|---|
| 1xx | Informational. The request continues. | None |
| 2xx | Success. | 200 OK |
| 3xx | Redirection. The client must follow a new location. | 301, 302, 307, 308 |
| 4xx | Client error. The request cannot be fulfilled. | 404, 410, 403, 429 |
| 5xx | Server error. A valid request failed. | 500, 503 |
Return 200 only for real pages
200 OK means the page loaded. Google can crawl, index, and rank it. Return 200 for every page you want in search results.
Do not return 200 for a page that does not exist. That creates a soft 404, which this article covers below.
Pick the right redirect
301 Moved Permanently
A 301 tells clients that the URL moved for good. Use it in four cases:
- You migrate a URL structure.
- You move to a new domain.
- You force one version of the site, such as
httptohttps, orwwwto the bare domain. - You merge duplicate pages into one URL.
Google follows the redirect and treats it as a strong signal that the target URL is canonical. It replaces the old URL with the new one in search results over time, usually within a few weeks. In 2016, Google's Gary Illyes said that 3xx redirects no longer lose PageRank. Older guides that say a 301 passes "90 to 99 percent" of link equity are out of date.
Request: GET /old-page
Response: 301 Moved Permanently
Location: /new-page
In Nginx:
location /old-page {
return 301 /new-page;
}
In Apache .htaccess:
Redirect 301 /old-page /new-page
In Next.js:
// next.config.js
module.exports = {
async redirects() {
return [
{
source: '/old-page',
destination: '/new-page',
permanent: true, // Next.js sends 308, not 301
},
];
},
};
Next.js sends 308 for permanent: true and 307 for permanent: false. Google treats 308 like 301 and 307 like 302, so the result for search is the same.
Keep a permanent redirect for at least one year, and longer while links still point to the old URL. If you remove a redirect, the old URL returns a 404. Any links that still point to it then lead nowhere.
302 Found
A 302 tells clients that the move is temporary and the original URL will return. Use it for a short promotion or a temporary maintenance page. Also use it for a test that sends some visitors to a variant.
Google follows a 302 but treats it as a weak canonical signal. It usually keeps the original URL in the index. That is the right result for a temporary move and the wrong result for a permanent one.
Request: GET /promo-page
Response: 302 Found
Location: /landing-page
A common mistake is a 302 for a permanent migration, often because it is a framework default. The new URLs then take longer to replace the old ones in search results. If a "temporary" redirect has been live for six months or more, it is permanent. Change it to 301.
307 and 308
A 307 Temporary Redirect is a 302 that keeps the HTTP method and body. A POST stays a POST. A 308 Permanent Redirect is a 301 with the same guarantee. A 301 or 302 can let a client change a POST into a GET.
Use 307 or 308 when you redirect form submissions or API calls that must keep their method. For search, Google treats 307 like 302 and 308 like 301. All current browsers support both codes.
Handle missing and removed pages
404 Not Found
A 404 means the server has no page at that URL. Use it when a page was deleted with no replacement, or when a URL was never valid. Also use it when temporary content expired and has no successor.
Google drops a URL that returns 404 from the index over time. No link value passes from a 404 page. Some 404s are normal: old URLs, broken external links, and typos. They do not hurt rankings on their own. Large numbers of 404s from your own internal links do waste crawl requests. Fix the internal links.
Request: GET /nonexistent-page
Response: 404 Not Found
Do not return 404 when a relevant replacement exists. Redirect to the replacement instead. Do not redirect every 404 to the homepage. Google treats an irrelevant redirect target as a soft 404. Check the Not found (404) reason in the Page indexing report in Search Console. Redirect or restore the pages that still get traffic or links.
410 Gone
A 410 means the page existed and was removed on purpose. Use it for discontinued products with no successor, expired promotions, and content you want out of the index.
location /deleted-product {
return 410;
}
Google's documentation treats all 4xx codes except 429 the same way: the content does not exist. Google staff have said that a 410 can drop a URL a little faster than a 404, but the difference is small. Use 410 when you know the removal is final. Use 404 in every other case. The out-of-stock pages guide covers the choice for ecommerce products.
403 Forbidden
A 403 means the server refuses the request. Use it for admin areas and other content that needs a login.
Googlebot does not log in. Google treats a 403 like other 4xx codes and does not index the page. A common mistake is a firewall or bot rule that returns 403 to Googlebot on public pages. Check your security rules if public pages disappear from the index.
429 Too Many Requests
A 429 asks the client to slow down. Google treats 429 like a server error. It reduces its crawl rate. Do not use 429 to block Googlebot for long periods.
Soft 404
A soft 404 is a page that returns 200 OK but shows "not found" content:
Request: GET /missing-page
Response: 200 OK
Body: <h1>404 - Page Not Found</h1>
Google detects many of these pages and excludes them, with the reason Soft 404 in the Page indexing report. The problem is waste. Google must fetch and analyze each one before it can exclude it. Pages that Google misreads can stay in the index as thin content.
Fix it by returning a real 404 with your custom error page. In Nginx, error_page serves the custom page with the 404 status:
error_page 404 /404.html;
location = /404.html {
internal;
}
In the Next.js Pages Router, pages/404.js returns a 404 status:
// pages/404.js
export default function Custom404() {
return <h1>404 - Page Not Found</h1>;
}
In the App Router, call notFound() in a route and add an app/not-found.js file for the content. Next.js then returns 404.
Respond to server errors
500 Internal Server Error
A 500 means the server failed. Common causes are a broken configuration, a code error such as an unhandled exception, and a lost database connection.
When Googlebot sees many 5xx responses, it slows its crawl rate. URLs that keep returning 5xx errors drop out of the index over time. A short outage of a few hours rarely causes lasting harm.
When 5xx errors appear:
- Read the server error logs.
- Fix the code or the configuration.
- Watch the
Server error (5xx)reason in thePage indexingreport in Search Console.
If robots.txt itself returns a 5xx error, Google pauses the crawl of the whole site until it can read the file again. Keep robots.txt on the most reliable part of your stack.
503 Service Unavailable
A 503 means the server is down for a short time, for planned maintenance, an upgrade, or overload. Google pauses and retries later. A 503 for a few hours causes no harm. If the site returns 503 for more than a few days, Google starts to treat the URLs as gone.
Send a Retry-After header that tells clients when to return. This value asks them to retry in one hour:
Response: 503 Service Unavailable
Retry-After: 3600
In Nginx, add the header with always, because Nginx adds headers to error responses only with that flag:
location / {
add_header Retry-After 3600 always;
return 503;
}
Remove redirect chains and loops
Chains
A chain is a redirect to a URL that redirects again:
/old-page → 301 → /intermediate-page → 301 → /final-page
Each hop costs a round trip for users and a crawl request for Googlebot. Googlebot follows up to 10 hops. After that, it reports a redirect error. Point every old URL straight at the final target:
/old-page → 301 → /new-page
/temp-page → 301 → /new-page
Find chains with Screaming Frog or Ahrefs Site Audit. The 301 redirect chain guide for developers covers bulk fixes after a migration.
Loops
A loop sends page A to page B and page B back to page A:
/page-a → 301 → /page-b
/page-b → 301 → /page-a
Neither page can be indexed, and users see a "too many redirects" error. Search Console reports loops under the Redirect error reason. Remove the circular rule.
Protect crawl capacity
Crawl budget is the number of URLs Googlebot will crawl on your site in a given period. It matters most for large sites. Some responses waste it: redirect chains, internal links to 404 pages, soft 404 pages, and repeated 5xx errors that Googlebot retries. Direct 301 redirects and correct 404 or 410 codes use it well. The robots.txt and crawl budget guide covers the other levers.
Your server logs show which status codes Googlebot received. The log file analysis guide shows how to read them.
Audit status codes on a schedule
In Google Search Console, open Indexing, then Pages. Check four reasons. Server error (5xx) needs a fix at once. Redirect error means a chain or a loop. Not found (404) needs a review of pages that still get traffic. Soft 404 means an error page returns 200.
In Screaming Frog:
- Crawl the site.
- Open
Response Codes, then filter toClient Error (4xx)orServer Error (5xx). - Export the URLs.
- Fix each URL or redirect it.
In Ahrefs Site Audit, run an audit, open Issues, and filter for broken pages and redirect chains. Export the list and fix it.
To check one URL, open Chrome DevTools, select the Network tab, and reload the page. The status column shows the code. From a terminal:
curl -I https://example.com/page
Use this quick reference
| Situation | Status code |
|---|---|
| The page loads | 200 OK |
| The URL moved for good | 301 Moved Permanently (or 308) |
| A short, temporary redirect | 302 Found (or 307) |
| The page was deleted with no replacement | 404 Not Found |
| The page was removed on purpose and will not return | 410 Gone |
| The page needs a login | 403 Forbidden |
| The server failed | 500 Internal Server Error |
| Planned maintenance | 503 Service Unavailable with Retry-After |
