About This HTML Issue
Understanding the 502 Bad Gateway Error
When you submit a URL to the W3C HTML Validator, the validator makes an HTTP request to fetch your page so it can analyze the markup. A 502 Bad Gateway status code means that some server acting as a gateway or proxy between the validator and your origin server received an invalid or incomplete response. Because the validator never receives your HTML content, it cannot perform any validation and reports this retrieval error instead.
This is fundamentally different from an HTML issue. Your markup could be perfectly valid, but the validator simply cannot see it. The problem lies somewhere in the chain of servers that handle the request.
Common Causes
A 502 error can be triggered by several infrastructure-level issues:
-
Origin server is down or crashing. If your web application (e.g., Node.js, PHP-FPM, Django) has crashed or is unresponsive, the reverse proxy (e.g., Nginx, Apache) sitting in front of it will return a
502. -
Server overload or timeout. If your application takes too long to generate a response, the gateway may time out and return a
502before the response is ready. -
CDN or proxy misconfiguration. Services like Cloudflare, AWS CloudFront, or Varnish may return
502if they cannot reach your origin server, or if SSL/TLS settings between the CDN and origin are mismatched. - Firewall or IP blocking. Your server’s firewall or hosting provider may be blocking requests from the validator’s IP address, causing the gateway to fail.
- DNS propagation issues. If you recently changed DNS records, some servers in the chain may be resolving to an outdated or invalid address.
-
Temporary networking issues. Transient network problems between servers can cause intermittent
502errors.
How to Fix It
Since this is not an HTML problem, you won’t be editing any markup. Instead, follow these steps:
-
Verify your site is accessible. Open the URL you’re trying to validate in your own browser. If you also see a
502error, the problem is on your server and needs to be fixed there first. - Check your server logs. Look at the error logs for your reverse proxy (Nginx, Apache) and your application server. They will usually indicate why the upstream connection failed.
- Inspect your CDN or proxy settings. If you use a CDN like Cloudflare, check its dashboard for error reports. Ensure the SSL mode matches your origin server’s configuration (e.g., “Full (Strict)” requires a valid certificate on your origin).
-
Confirm no IP-based blocking. The W3C Validator makes requests from its own servers. Make sure your firewall,
.htaccessrules, or hosting provider aren’t blocking external automated requests. - Check for authentication barriers. If your site requires HTTP authentication, a login, or is behind a VPN, the validator cannot access it. You’ll need to use the validator’s “Validate by Direct Input” option instead, pasting your HTML directly.
- Wait and retry. If the issue is a temporary server overload or network blip, simply waiting a few minutes and trying again may resolve it.
- Contact your hosting provider. If the error persists and you can’t identify the cause, your hosting support team can investigate the server-side issue.
Alternatives When Your Server Is Unavailable
If you cannot resolve the server issue immediately but still need to validate your HTML, you have two options that bypass the URL fetch entirely:
Validate by Direct Input
Go to the W3C Validator, select the “Validate by Direct Input” tab, and paste your HTML source code directly.
Validate by File Upload
Select the “Validate by File Upload” tab and upload your .html file from your local machine.
Examples
Even though this error is not caused by HTML, here’s an illustration of valid markup you might be trying to validate when encountering this issue:
A valid HTML page that the validator cannot reach
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Page</title>
</head>
<body>
<h1>Welcome</h1>
<p>This page is perfectly valid, but the validator cannot fetch it due to a 502 error.</p>
</body>
</html>
If submitting the URL https://example.com/my-page produces the “HTTP resource not retrievable (502)” message, paste the above source code into the “Validate by Direct Input” field instead. The validator will then be able to check your markup without needing to fetch it from the server.
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.
Learn more: