HTTP errors: what 500, 502, 503 and 504 mean

HTTP errors: what 500, 502, 503 and 504 mean
When you try to open a page and a blank screen appears with a large number and a message in English, the usual reaction is confusion: did the site go down? Is it my connection? Did I break something? Those numbers are not random: they are HTTP status codes, the standard way a web server tells the browser (and you) what happened to your request. Understanding what each code means turns a mysterious problem into a concrete diagnosis. And while dozens of codes exist, most of the errors you will see on a small website come down to four: 500, 502, 503 and 504. In this article we explain what HTTP codes are, what each of those four errors indicates, how they differ from one another, and the steps you can take to fix them.What are HTTP status codes?
Every time you open a page, your browser sends an HTTP request to the server that hosts the site. The server processes that request and replies with a three-digit code that summarizes the outcome: whether everything went fine, the page moved to a new address, the request was malformed, or the server could not complete it. These codes are defined in open standards maintained by the IETF and are grouped by their first digit. That first number is not a minor detail: it immediately tells you which side the problem is on. Codes starting with 4 point to a failure in the request you sent; codes starting with 5 point to a failure on the server side. That distinction is the key to avoiding wasted time looking for the problem in the wrong place.The five HTTP code groups
There are five groups, and knowing them lets you interpret any code you come across, even one you have never seen before:- 1xx: informational. The server received the request and is still processing it. These are temporary and you will rarely see them as a user.
- 2xx: success. The request was processed correctly. The best known is 200 OK, which means the page loaded without issues.
- 3xx: redirections. The resource moved and the browser must go to another address. Typical examples are 301 (moved permanently) and 302 (moved temporarily).
- 4xx: client errors. The server understood the request but cannot fulfill it because the problem lies in what was asked for. The most famous is 404 (page not found), along with 400 (bad request) and 403 (forbidden).
- 5xx: server errors. The server failed while trying to fulfill a request that was valid to begin with. This is where 500, 502, 503 and 504 live, the main characters of this article.
The most common codes and what they mean
Before diving into 5xx errors, it is worth having a full picture of the codes that appear most often in practice. This table summarizes the seven you will run into the most:| Code | Meaning | Common cause | Basic fix |
|---|---|---|---|
| 200 | Success: the page loaded correctly. | None; this is the normal response. | No action needed. |
| 301 | Permanent redirect to another URL. | The page changed its address. | Update links and bookmarks to the new URL. |
| 404 | The requested resource was not found. | Misspelled URL, broken link or deleted page. | Fix or redirect the link; check the URL spelling. |
| 500 | Internal server error. | Failure in the code, configuration or permissions. | Check the error logs and the latest update. |
| 502 | Invalid response from an intermediate or upstream server. | The application server or PHP-FPM stopped. | Restart the services and make sure they are running. |
| 503 | Service temporarily unavailable. | Maintenance, overload or resource limits. | Wait, check resource usage or bring the site back up. |
| 504 | The gateway ran out of waiting time. | A script or process takes too long to respond. | Raise the time limit or optimize the slow process. |
500 Internal Server Error: the server failed internally
The 500 Internal Server Error is the most generic of them all. The server received a valid request, tried to process it, and failed for a reason it cannot specify itself. That is why the message is so unhelpful: it is the server's way of saying that something broke and it does not know exactly what. On small websites, the most frequent causes are programming errors, such as a syntax error in PHP or a plugin incompatible with the current version of the platform; corrupted configuration files, such as an .htaccess with an invalid directive; incorrect permissions on files or folders; or a server memory limit that ran out while handling a heavy task. It is also common for the error to appear right after an update: the theme, plugin or site core was updated and something stopped being compatible. What to do about a 500:- Figure out when it started. If the error appeared after an update or a recent change, that change is the most likely culprit.
- Check the error logs. Most hosting panels include the site's error logs. The exact line of the failing file usually shows up there.
- Enable error display temporarily if you have access to the code, only in a development environment: it will tell you the file and line of the problem.
- Check file and folder permissions and the contents of the .htaccess file.
- Restart your site's service (Apache, PHP-FPM or the application service) from the control panel.
- If the site runs on shared hosting and you cannot find the cause, contact support and send them the error exactly as it appears, along with when it started.
502 Bad Gateway: the messenger could not get through
The 502 Bad Gateway error points to a communication problem between two servers. Most websites have an intermediate layer: a proxy server or gateway (for example, Nginx) that receives the visitor's request and forwards it to the server that actually generates the page (for example, Apache or PHP-FPM). When that application server does not respond or replies with an invalid response, the gateway returns a 502. The key difference from the 500 is that the site itself may be perfectly fine: the code has no errors. The problem is that the process that should run it stopped, restarted halfway through the request, or is not listening. Typical causes include a crashed PHP-FPM process, a stopped application server, a restart in progress, a firewall blocking the connection between services, or a traffic spike that left the process without resources. What to do about a 502:- Make sure the services are running. From the hosting panel, check that PHP-FPM, Apache or the application service is up, and restart it if needed.
- Try again in a few minutes. Many 502 errors are transient and disappear on their own once the service restarts.
- Check the server and error logs to see whether a process crashed due to lack of memory or a failure.
- If you use a proxy or CDN such as Cloudflare, confirm that the origin server is reachable and that the firewall is not blocking its connections.
- If services keep crashing, the problem is usually resources: contact your hosting provider to review your plan's limits.
503 Service Unavailable: the service is not available right now
The 503 Service Unavailable error means the server is alive and working, but it cannot handle the request at this moment. Unlike the 500, here the server does know why it is not responding: it is under maintenance, it is overloaded, or it is restarting. This code has two sides. One is legitimate and even desirable: many sites activate a maintenance page that returns a 503 while being updated, so visitors know the site will come back and search engines do not index a half-built page. The other side is the problematic one: a traffic spike that exceeds the server's capacity, a process consuming all the memory, or a saturated database that leaves the site unable to respond. What to do about a 503:- Check whether the maintenance is intentional. If you (or someone on your team) are updating the site, the 503 is normal: wait for it to finish and take the site out of maintenance mode.
- Check resource usage. Go to the hosting panel and look at CPU, memory and connection usage over the last few minutes. If it is at the limit, the server is rejecting requests to avoid collapsing.
- Wait a few minutes before retrying. If it was a traffic spike or a restart, the site should come back on its own.
- Restart the service if the overloaded state persists.
- If the 503 shows up frequently, your hosting plan has run out of headroom: talk to your provider about adding resources or switching plans.
504 Gateway Timeout: the wait ran out
The 504 Gateway Timeout error appears when the gateway did manage to talk to the application server, but that server took too long to respond and the maximum waiting time was exceeded. In other words: the intermediate server asked the question, waited the allowed time and, with no answer coming, told the browser that time was up. Here lies the practical difference from the 502: with a 502 the response is invalid or never arrives; with a 504 the response simply arrives too late. This usually points to a slow process underneath: a script that runs longer than the configuration allows (for example, PHP's maximum execution time), a very heavy database query, an external service that is not responding, or an overloaded server that puts every request into a long queue. What to do about a 504:- Reload the page. If the site responds on the second or third load, the problem was a one-off spike.
- Find the slow process. Check the logs and slow database queries: there is usually one specific script that runs for a very long time.
- Raise the time limits. If you use Nginx as a proxy, review directives such as proxy_read_timeout or fastcgi_read_timeout, plus PHP's maximum execution time. Do this carefully: extending the limit does not fix the cause, it only buys more time.
- Optimize rather than patch. A query that takes sixty seconds is better solved with a database index or a cache than with a limit of three hundred seconds.
- If you do not have access to that configuration, your hosting provider can help you adjust the timeouts or identify the process that is saturating the server.
How to tell the four 5xx errors apart
When your site shows a 5xx error, this quick rule helps you locate the problem:- 500: the server failed while running the application. Check the code, the logs and the latest update.
- 502: the gateway did not get a valid response from the application server. Restart and verify the services.
- 503: the server is available but cannot handle requests right now. It is usually maintenance or overload.
- 504: the gateway got a response, but too late. Look for the slow process and raise or optimize the timeouts.
Action order when facing a 5xx error
If you do not know where to start, follow this order: it covers the most likely cases first and leaves hosting support as a last resort, not as the first option.- Check whether the error is widespread. Try from another network, your phone or a private browsing window. If it only fails for you, it may be a local problem (even a browser cache holding the error page).
- Restart. Stop and start your site's service again from the hosting panel. A significant share of 5xx errors is resolved with a restart.
- Check the logs. The error logs in the panel usually point to the exact file and line of the problem.
- Check the resources. CPU and memory at their limit explain many 502, 503 and 504 errors.
- Undo the last change. If the error came after an update, roll back that plugin, theme or configuration to the previous version.
- Contact hosting support with all the information: which error you see, since when, what you changed beforehand and what the logs say. On shared hosting, some settings (such as proxy timeouts or server configuration) can only be changed by the provider.