500 Internal Server Error: Finding the Real Cause

500 Internal Server Error is the generic code a server returns when its own code or configuration fails and nothing more specific fits. The page hides the detail on purpose. The real message, such as a PHP fatal error, an exception or a bad .htaccess line, is waiting in the server's error log.

Where the real 500 error is logged
StackLog locationCommon cause
Apache/var/log/apache2/error.logInvalid directive in .htaccess
WordPresswp-content/debug.log with WP_DEBUG_LOG onPlugin or theme fatal error
PHP-FPMPHP-FPM log and the pool's error_logMemory limit exhausted
Node or ExpressProcess output or your log serviceUnhandled exception in a route
Vercel functionsProject Logs, filtered by the requestMissing environment variable

Updated

Every visitor sees the same bland page, which is good for security and bad for debugging. Treat a 500 as a pointer to the logs. Note the exact time and URL of a failing request, then search the log for that moment.

Get the real error

WordPress: log errors without showing them

Add above the line that says That's all, stop editing in wp-config.php.

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

Express: one error handler that logs the stack

Register it after all routes. The four parameters are required.

app.use((err, req, res, next) => {
  console.error(req.method, req.url, err.stack);
  res.status(500).json({ error: "Internal Server Error" });
});

Turning logs on when you cannot see any

On shared hosting, the control panel usually has an Errors or Logs section. In WordPress, set WP_DEBUG and WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false, so errors are written to wp-content/debug.log but hidden from visitors.

In Node, wrap async route handlers so rejected promises reach an error middleware that logs the stack. An Express error handler takes four arguments; with fewer, Express does not treat it as one.

Preventing repeat 500s

Add an error tracker that captures the stack and request, and alert on a rise in 5xx responses. Check that required environment variables exist at startup so a missing secret fails the deploy instead of live traffic.

A We.Inc site has no server code of yours that can throw, so a 500 there is ours to fix; send the page address and time to support.

How it works

  1. Reproduce the error and write down the URL and time.
  2. Open the error log for your stack from the table and find that request.
  3. Read the first error, not the last, since later ones are often side effects.
  4. Fix the code or config, deploy, and request the same URL again.

Tips

  • If the 500 started right after a deploy, roll back first and debug second. Visitors get a working site while you read logs.
  • An Apache 500 that appears on every page at once after editing .htaccess almost always means a typo or a module that is not enabled, such as mod_rewrite.
  • Missing environment variables in production cause many first-deploy 500s, because the code worked locally with a .env file that was never uploaded.
  • Never turn on detailed error display for public traffic. Log errors to a file and keep display off.

Frequently asked questions

What does HTTP code 500 mean?

It means Internal Server Error: the server hit an unexpected condition that stopped it from completing the request. It says something broke on the server, not what broke.

Can I fix a 500 error as a visitor?

Rarely. Reload once, then try later. The failure is in the site's code, so only its owner can fix it, though reporting the URL and time helps them.

How do I fix 500 Internal Server Error in WordPress?

Rename the .htaccess file to rule it out, then disable plugins by renaming wp-content/plugins. Turn on WP_DEBUG_LOG to capture the fatal error and raise the PHP memory limit if the log says memory was exhausted.

What is the difference between 500 and 502?

A 500 comes from the application server itself reporting its own failure. A 502 comes from a proxy in front saying the app behind it gave no valid response.

Does a 500 error affect SEO?

Brief ones do not. If Google keeps getting 500s, it crawls less and may drop affected pages until they recover.

Related: 502 Bad Gateway, 503 Service Unavailable, WordPress .htaccess, HTTP status codes.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Guides

Product

Who It's For

Features

Resources

Company

View Sitemap