Sub topic 3
What makes a link broken: status codes, redirects and soft 404s
A link is broken when a visitor who follows it cannot reach the content the author meant to point to. A browser can show a page and still fail that test. This chapter explains how to read HTTP responses so you can classify a link correctly before you spend time on outreach.
This chapter assumes you know what a backlink and an anchor tag are, and that you recognize common status codes such as 200, 301 and 404. It also assumes you can read basic Python. The goal is a working model of what "broken" means, plus the errors that cause false positives and missed opportunities.
Why the definition matters
In broken link building you email a site owner and say a link on their page is dead. If the link actually works, you lose credibility. If you miss a link that is dead in practice, you lose an opportunity. Both errors come from relying on a single signal, usually the status code alone.
Three questions help you classify any outbound link:
- Did the request connect at all?
- What status code did the final response return, after any redirects?
- Does the final page still deliver what the anchor text promised?
Status code classes
An HTTP status code is a three-digit number a server returns with every response. The first digit gives the class.
| Class | Meaning | Broken? |
|---|---|---|
| 2xx | Success | Usually working, but check for soft 404s |
| 3xx | Redirect | Follow the chain, then judge the final response |
| 4xx | Client error | 404 and 410 are broken. Others need judgment |
| 5xx | Server error | Possibly broken. Retry before you decide |
Codes you will see most
- 200 OK. The page loaded. This does not prove the content is still there.
- 301 and 308. The page moved permanently. The link still works, but it is often a sign that the target changed.
- 302, 303 and 307. The move is temporary. Treat the link as working unless the chain ends badly.
- 404 Not Found. The server has no page at that URL. This is the classic broken link.
- 410 Gone. The server says the page was removed on purpose. It is as broken as a 404, and it is a stronger signal that the content will not return.
- 403 Forbidden. The server refused the request. A real visitor in a browser may get through, so do not call this broken without a second check.
- 405 Method Not Allowed and 501 Not Implemented. Some servers reject
HEADrequests. Retry withGET. - 429 Too Many Requests. You are going too fast. Slow down and retry. This says nothing about the link.
- 500, 502, 503 and 504. The server failed or is overloaded. A single 503 may be a short outage.
Connection failures
Some links never return a status code. The request fails before the server can answer. Common causes:
- The domain has expired or no longer resolves in DNS.
- The server refuses connections or times out.
- The TLS certificate is invalid or expired.
A dead domain is a strong prospect. The site that linked to it has lost the target completely, and no redirect can rescue it. Check twice, on different days, before you label it dead. A temporary DNS or network problem looks identical to a permanent one in a single request.
Redirects
A redirect sends the visitor from one URL to another. Redirects create the most borderline cases, so follow the chain to its end and judge the final response.
Watch for these redirect patterns:
- Redirect to a relevant page. The old URL leads to the new location of the same content. The link works. Do not pitch it as broken.
- Redirect to the homepage. The old page was removed and the server sends every visitor to the root. The link technically returns 200, but the visitor does not get what the anchor promised. Treat this as broken.
- Redirect loop. URL A redirects to B and B redirects back to A. Browsers stop after a limit and show an error. Count it as broken.
- Long chains. Several redirects in a row slow the visitor down, but the link works if the chain ends well.
Python's requests library follows up to 30 redirects by default and raises TooManyRedirects after that. You can inspect resp.history to see each hop and resp.url for the final address.
Soft 404s
A soft 404 is a page that tells the visitor the content is missing but returns a 200 status code. The server replies "success" while the page says "Sorry, we couldn't find that." Search engines also report this condition, because a missing page that returns 200 looks like real content.
Soft 404s hide dead links from any checker that only reads status codes. Typical signs:
- The page title or heading contains phrases such as "not found", "no longer available" or "page doesn't exist".
- The page body is very short compared to normal pages on the site.
- Many different missing URLs return the same title and content.
- The final URL after redirects is a homepage, a search page or a category page.
No single sign is conclusive, so combine them. The function below flags a 200 response as a probable soft 404 when it matches at least one text phrase or lands on a different path that is the site root.
import requests
from urllib.parse import urlparse
HEADERS = {"User-Agent": "link-audit/1.0"}
SOFT_404_PHRASES = (
"page not found",
"not found",
"no longer available",
"does not exist",
"doesn't exist",
)
def classify_link(url, timeout=10):
try:
resp = requests.get(url, headers=HEADERS, timeout=timeout)
except requests.TooManyRedirects:
return "broken: redirect loop"
except requests.RequestException:
return "broken: connection failure"
if resp.status_code in (404, 410):
return f"broken: {resp.status_code}"
if resp.status_code >= 500:
return f"retry: {resp.status_code}"
if resp.status_code in (403, 429):
return f"unclear: {resp.status_code}"
if resp.status_code >= 400:
return f"unclear: {resp.status_code}"
original_path = urlparse(url).path.strip("/")
final_path = urlparse(resp.url).path.strip("/")
if original_path and not final_path:
return "broken: redirected to homepage"
text = resp.text.lower()
if any(phrase in text[:5000] for phrase in SOFT_404_PHRASES):
return "probable soft 404: check by hand"
return f"working: {resp.status_code}"
if __name__ == "__main__":
print(classify_link("https://example.com/"))The phrase check is deliberately loose. A real article about "page not found errors" would trigger it, so the function reports a probable soft 404 and leaves the final decision to you.
Common errors
Trusting HEAD requests
A HEAD request asks for headers only. It is fast, but some servers answer it differently than a GET. If HEAD returns 403, 405 or 501, repeat the check with GET before you decide.
Treating blocks as broken
Some sites return 403 to automated clients or to your IP range. Set a clear User-Agent, keep your request rate low, and open the page in a browser before you claim it is dead.
Labeling a single failure as permanent
A 503 or a timeout can be a brief outage. Re-check later, ideally on a second day, and record the date of each check.
Ignoring the anchor's promise
A link whose anchor says "2019 pricing report" and that lands on a generic blog index returns 200 and is still useless to the reader. Compare the final page to what the anchor and surrounding sentence promise.
Missing links that are broken only for some visitors
A page may break only for certain countries or devices, or behind a login. If a link requires an account to view, treat it as unclear, not broken.
A practical decision rule
Use this order when you review a list of outbound links:
- Discard non-HTTP links such as
mailto:andtel:. - Request each URL with a clear user agent and a timeout.
- Follow redirects and read the final status code and final URL.
- Mark 404, 410, dead domains and redirect loops as broken.
- Mark homepage redirects and soft 404s as broken after a manual look.
- Re-check 5xx and timeouts later. Do not pitch them yet.
- Leave 403 and 429 as unclear until you confirm in a browser.
Exercise
A resource page links to https://old-vendor.example/guide. A request returns 301 to https://old-vendor.example/, and that page returns 200 with the vendor's homepage. Is the link broken, and what would you do before pitching it?
Show answer
Treat it as broken in practice. The status code is 200 at the end, but the redirect goes to the homepage, so the visitor does not get the guide the anchor promised. Before pitching, open the link in a browser to confirm it lands on the homepage, check the web archive to see what the guide covered, and record the check date.
Exercise
Your script reports a 503 for a link and a 404 for another. Which one can you pitch today, and why?
Show answer
Only the 404. A 404 means the server has no page at that address. A 503 can be a short outage, so re-check it later, ideally on another day, and pitch it only if the error persists.