500, 502, 503, 504 and 508 Server Errors: What They Mean and How to Fix

A 5xx error means the request reached the server but the server failed to produce a page. A 500 is a generic crash in your site's code or configuration, a 502 means a proxy got a bad answer from the application behind it, a 503 means the server is temporarily refusing work, a 504 means the proxy gave up waiting, and a 508 on shared hosting usually means your account hit its resource limits. The fastest fix almost always starts the same way: read the error log at the minute the error happened.
What each error code actually tells you
500 Internal Server Error: PHP or the web server hit a fatal problem. Typical causes: a broken
.htaccessrule, a plugin or theme fatal error, the wrong PHP version, exhausted memory, or bad file permissions.502 Bad Gateway: a proxy (nginx, a load balancer, a CDN) sits in front of an application (PHP-FPM, Gunicorn, Node.js) and got nothing usable back. The app is down, crashed mid-request, or listens on a different socket or port than expected.
503 Service Unavailable: the server is up but not serving: maintenance mode, all PHP workers busy, a rate limit, or an overloaded backend.
504 Gateway Timeout: the proxy waited longer than its timeout (60 seconds is the nginx default) and stopped. The app is alive but too slow: a heavy query, a stuck API call, or a long import running inside a web request.
508 Resource Limit Is Reached: on cPanel hosting with CloudLinux, this appears when an account exceeds its share of processes, CPU or memory. (In the HTTP standard 508 means "Loop Detected" for WebDAV, but that is rare on normal websites.)
The first five minutes: checks that apply to every 5xx
Confirm it is not just you. Open the site from mobile data. If it loads there, suspect a local cache, VPN or firewall.
Check the exact status code and time. A browser page can hide the real code, especially behind a CDN. From any terminal (replace example.com with your domain):
curl -sS -o /dev/null -w "%{http_code} %{time_total}s\n" https://example.com/Note the time and time zone; logs work in timestamps.
Ask what changed. A plugin update, a new PHP version, an edited
.htaccess, a campaign traffic spike. Most 500 errors appear minutes after a change.Every page or one URL? One broken URL points to a specific script. The whole site failing points to configuration, PHP, the database or resources.
How to read error logs on shared hosting and on a VPS
On cPanel, Metrics → Errors shows recent web server errors. PHP errors often land in a file named error_log inside the folder of the script that failed, for example public_html/error_log or public_html/wp-admin/error_log. The newest lines are at the bottom.
For WordPress, turn on the debug log temporarily by adding these lines to wp-config.php above the line that says "That's all, stop editing":
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );Reload the broken page, read wp-content/debug.log, then turn debugging off again.
On a Linux VPS with nginx, watch the log live while you reload the page:
sudo tail -f /var/log/nginx/error.logWith Apache it is /var/log/apache2/error.log. For systemd services (PHP-FPM, Gunicorn, Node), use journalctl.
Fixing a 500 error on shared hosting and WordPress
1. Rule out .htaccess
Rename .htaccess to .htaccess.bak in File Manager (enable "show hidden files"). If the homepage returns, the file was the problem. For WordPress, recreate it by going to Settings → Permalinks and clicking Save, or paste the default block:
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPressThen add custom rules back one at a time. One unsupported directive (such as php_value on a server running PHP-FPM) is enough to cause a 500.
2. Check the PHP version
If the log shows "Call to undefined function" or a syntax error in a file you did not edit, switch back in cPanel (MultiPHP Manager or Select PHP Version) to the version the site last worked on, then plan the upgrade.
3. Isolate the plugin or theme
If you cannot reach wp-admin, rename wp-content/plugins to plugins.off. If the site loads, rename it back and disable plugins one by one by renaming their folders. The log usually names the guilty folder anyway.
4. Memory exhausted
The message "Allowed memory size of 134217728 bytes exhausted" means PHP hit its 128 MB limit. You can raise WordPress's limit with define( 'WP_MEMORY_LIMIT', '256M' ); in wp-config.php, but it cannot exceed PHP's memory_limit in cPanel. A page that needs more than 256 MB has a plugin or query problem.
5. File permissions
On most cPanel servers, folders should be 755 and files 644. Setting 777 "to make it work" often causes a 500, because the server refuses world-writable scripts. With cPanel Terminal:
find ~/public_html -type d -exec chmod 755 {} \;
find ~/public_html -type f -exec chmod 644 {} \;Fixing a 508 Resource Limit Is Reached error
A 508 is not a code bug. Too many processes ran at once for your account, usually because PHP built every request from scratch. Usual culprits: no page caching, bots crawling search or filter URLs, brute-force hits on wp-login.php or xmlrpc.php, WP-Cron firing on every visit, or backups running at peak hours. Resource Usage in cPanel shows which limit was hit and when.
Fixes in order of impact: enable page caching, block or rate-limit abusive bots, move WP-Cron to a real cron job, and schedule backups at night. Storage and file-count limits can also break sites in less obvious ways; our guide on disk space, bandwidth and inodes explains each limit. On IM HOST shared hosting, heavy usage is throttled under fair use rather than suspended, so treat a 508 as a signal to find what is consuming resources. If the cause is slow pages rather than traffic, work through these common causes of a slow WordPress site first.
Fixing 502, 503 and 504 on a VPS
502 Bad Gateway: is the upstream running?
Check the service and the socket nginx is pointing at. Replace 8.3 with your PHP version (8.1 on Ubuntu 22.04, 8.2 on Debian 12):
sudo systemctl status php8.3-fpm
ls -l /run/php/
sudo journalctl -u php8.3-fpm --since "30 min ago"In the nginx log, connect() to unix:/run/php/php8.3-fpm.sock failed (2: No such file or directory) means the socket path in your site config does not match the running PHP version. connect() failed (111: Connection refused) means nothing listens on that port: your Gunicorn or Node service is stopped or crashed. Check it with sudo journalctl -u yourapp -n 100.
Intermittent 502s are often the kernel killing processes for lack of memory:
sudo dmesg -T | grep -i -E "out of memory|killed process"
free -m
df -hA full disk also causes odd 500 and 502 errors.
503 Service Unavailable: workers or limits
If /var/log/php8.3-fpm.log shows "server reached pm.max_children setting", every PHP worker was busy. A rule of thumb for sizing: RAM you can give PHP divided by the average worker size. Measure the average:
ps --no-headers -o rss -C php-fpm8.3 | awk '{s+=$1} END {print s/NR/1024 " MB"}'With 1.5 GB for PHP and 60 MB per worker, about 25 workers is the ceiling; going higher trades 503s for memory kills. Also, nginx's limit_req returns 503 by default when a client exceeds the rate, and WordPress shows a 503 while a .maintenance file exists in the site root after an interrupted update. Delete that file and the site returns.
504 Gateway Timeout: something is slow
The log line upstream timed out (110: Connection timed out) while reading response header from upstream confirms it. Raising fastcgi_read_timeout or proxy_read_timeout hides the symptom. Enable the database slow query log, check external API calls, and move long tasks (imports, reports, bulk email) to a background queue. If the server is simply too small for the workload, a plan with dedicated resources such as Cloud VPS with dedicated vCPU and RAM removes contention from noisy neighbours, but it will not fix a query that scans a million rows.
When to contact support, and what to send
Contact your host when the log points to the server rather than your code, when errors start with no change on your side, or when you cannot reach the logs. Send everything in one message:
The exact URL and the error code.
Date, time and time zone of a failed request.
What changed before it started, and what you already tried.
The relevant log lines, copied as text.
On a VPS: the output of
systemctl statusfor the failing service,free -manddf -h.
If errors keep returning, start measuring them. Knowing how many minutes your site was down each month turns a vague complaint into a number you can compare against what a 99.9% uptime SLA really allows.
Frequently asked questions
Is a 500 Internal Server Error my fault or the host's?
Usually it comes from the site: a plugin, theme, .htaccess rule or PHP setting. If several unrelated sites fail at the same moment with no change on your side, the server is more likely. The error log settles it.
Do 5xx errors hurt SEO?
A few minutes will not; search engines retry. Errors lasting days slow crawling and can drop affected pages from the index until they recover. For planned maintenance, return a 503 with a Retry-After header instead of a 500 or a blank page.
How do I fix a 503 error in WordPress after an update?
Delete the .maintenance file from the site's root folder using File Manager or FTP. WordPress creates it during updates and removes it when they finish; if the update is interrupted, the file stays and the site keeps returning 503.
If your site has outgrown the limits that keep causing 508 or 503 errors, compare shared hosting plans with Cloud VPS plans and pick the step that fits your traffic. Our engineers are available 24/7 if you want a second pair of eyes on a log.
More from our blog
Discover more practical guides and product insights from the IM Host team.
View all articles