500 Internal Server Error: Causes and How to Fix It

500 Internal Server Error: Causes and How to Fix It

  1. Home
  2. Blogs
  3. 500 Internal Server Error: Causes and How to Fix It

500 Internal Server Error means something went wrong on the server — but the server won't tell the visitor what. It's the least informative error: it has dozens of possible causes. The good news is that the cause is almost always written in the logs and can be found in minutes. Here's what visitors can do and how site owners can find and fix the problem.

What a 500 error means

Code 500 is a generic server error: the request reached the site, but the application (PHP, Python, Node.js) or the web server couldn't process it because of an internal failure. Unlike 502 and 504, the problem isn't the link between the web server and the application but inside the application or its settings.

What to do as a visitor

  1. Reload the page after a minute — sometimes the error is temporary.
  2. Clear the site's cache and cookies or open it in incognito mode.
  3. If the error appears on every page, let the site owner know: a visitor can't fix it.

Common causes of a 500 error

Cause Typical sign
A PHP code error (syntax, calling a missing function) "PHP Fatal error" in the log
A plugin or theme conflict (WordPress, Joomla) the error appeared after an update or install
An invalid directive in .htaccess (Apache) "Invalid command" or "RewriteRule" in error.log
PHP memory limit too low (memory_limit) "Allowed memory size exhausted"
Wrong file and folder permissions "Permission denied" in the log
Database connection failure "Error establishing a database connection" / "Connection refused"
Script execution time exceeded "Maximum execution time exceeded"

How to fix a 500 error: step by step

Step 1. Find the cause in the logs

Connect to the server via SSH and check the latest log entries:

# Nginx
sudo tail -n 50 /var/log/nginx/error.log
# Apache
sudo tail -n 50 /var/log/apache2/error.log
# PHP-FPM
sudo tail -n 50 /var/log/php8.3-fpm.log

Look for lines with Fatal error, Permission denied or memory — they usually include the file and line number.

Step 2. Turn on error logging while debugging

For WordPress, add to wp-config.php:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Errors will be written to wp-content/debug.log. Turn debugging off once fixed.

Step 3. Check plugins and the theme

If the error appeared after an update, rename the wp-content/plugins folder via SFTP — all plugins will be disabled. If the site works, bring plugins back one by one to find the culprit. Do the same with the theme by temporarily switching to a default one.

Step 4. Check .htaccess (Apache)

Rename the .htaccess file in the site root. If the error disappears, it contains an invalid directive. In WordPress you can regenerate the default file under Settings → Permalinks.

Step 5. Raise PHP memory and execution time

# php.ini or the PHP-FPM pool
memory_limit = 256M
max_execution_time = 120

Restart PHP-FPM afterwards: sudo systemctl restart php8.3-fpm.

Step 6. Check file permissions

sudo chown -R www-data:www-data /var/www/site
sudo find /var/www/site -type d -exec chmod 755 {} \;
sudo find /var/www/site -type f -exec chmod 644 {} \;

Step 7. Check the database

sudo systemctl status mysql
sudo systemctl restart mysql

Verify the database name, user and password in the site config.

Code Meaning
500 Internal application or server error
502 The gateway (Nginx) got an invalid response from the backend
503 Service temporarily unavailable: overload or maintenance
504 The backend didn't respond in time

For details on 502, see our article "502 Bad Gateway Error: What It Means and How to Fix It".

How to reduce the risk of 500 errors

  • Test plugin and CMS updates on a staging copy first.
  • Back up before updating — rolling back then takes minutes.
  • Watch server memory: with a constant lack of resources, errors become regular.
  • Set up monitoring with Telegram alerts.

If your site has outgrown its current hosting, move it to a PSB Hosting VPS: dedicated resources, root access and full control over PHP and web server settings.

FAQ

Is a 500 error the host's fault or the site's?

Usually the site's: code, plugins, settings. Hosting problems typically show up as 502, 503 or the server being unreachable.

Does a 500 error affect search rankings?

A one-off doesn't. If search bots get a 500 for several days, pages may drop out of the index.

Why does the 500 error appear on only one page?

The failure is in code or data used only on that page: a template, a shortcode, a database query. Look for the log entry with the time you opened that page.

Related articles

Buysellacc.com: a Platform for MMO Accounts and Digital Services

Buysellacc.com: a Platform for MMO Accounts and Digital Services

Partner content. Prepared by the Buysellacc team. Buysellacc.com is a platform with an automated system for MMO accounts and digital services. It works for individuals, collaborators, resellers and b

How to Connect to a Server via SSH: Windows, macOS and Linux Step by Step

How to Connect to a Server via SSH: Windows, macOS and Linux Step by Step

SSH is the standard way to manage a VPS or dedicated server: you use it to install software, edit configs, read logs and restart services. This guide shows how to connect to a server via SSH from Wind

Money Safe Review: a Service for Manually Built White Pages for Media Buyers

Money Safe Review: a Service for Manually Built White Pages for Media Buyers

Partner content. Prepared by the Money Safe team. In affiliate marketing, there haven’t been any one-size-fits-all solutions that guarantee passing moderation for quite some time. The algorithm

502 Bad Gateway Error: What It Means and How to Fix It

502 Bad Gateway Error: What It Means and How to Fix It

502 Bad Gateway is one of the most common website errors: you open a page and get a blank screen saying "502 Bad Gateway". Let's look at what it means, who is to blame — the browser, the site or

ProxiesTrust.com: Multi-Country Proxies with Stable Performance

ProxiesTrust.com: Multi-Country Proxies with Stable Performance

Partner content. Prepared by the ProxiesTrust team. ProxiesTrust.com is a multi-country proxy service that partners value for its stability and performance. It is built for long-term use at a reasona

IpsTrust.com: Stable Proxies at Competitive Prices

IpsTrust.com: Stable Proxies at Competitive Prices

Partner content. Prepared by the IpsTrust team. Looking for reliable proxies for digital marketing, account management or system operations? IpsTrust.com provides proxy services built around a few si

TDS.ceo: a Tracker for Affiliate Marketing and Fast Traffic Launches

TDS.ceo: a Tracker for Affiliate Marketing and Fast Traffic Launches

Partner content. Prepared by the TDS.ceo team. When you launch traffic, you need to see what happens after the click: how many users reached the offer, where conversions came from, what the result co

FreePWA.com: Free PWAs for Gambling, Betting and Dating — and Your Own White-Label Service

FreePWA.com: Free PWAs for Gambling, Betting and Dating — and Your Own White-Label Service

Partner content. Prepared by the FreePWA team. In affiliate marketing you want to get to launch faster: pick an offer, prepare an app for the geo and send traffic. When every new idea means calculati

GetAntik: an Antidetect Browser with HollyProxy Proxies and TDS.ceo Statistics

GetAntik: an Antidetect Browser with HollyProxy Proxies and TDS.ceo Statistics

Partner content. Prepared by the GetAntik team. Working with multiple accounts quickly fills up with small tasks. One profile needs its proxy renewed, another has to be handed over to a colleague, an

Telegram