Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What a 500 Error Means

A 500 Internal Server Error is a catch-all. The server received the request, tried to handle it, and hit an error it had no more specific status code for. The web server, PHP, or the application failed; the visitor's browser and connection are fine. The exact reason is almost always written in a log file on the server.

A 4xx code points at the request and a 5xx code points at the server. The full list is in HTTP status codes explained.

If You See It on Someone Else's Site

  • Reload once: a 500 caused by a restart during a deployment can clear within seconds.
  • Try another page: if only one page fails, the fault is in that page's code.
  • Come back later or tell the site owner: clearing your cache or changing browsers does not help, because the error happens on the server.

Start with the Error Logs

Reproduce the error, then read the log of the software that served the page:

SoftwareDebian and UbuntuAlmaLinux and Rocky Linux
Nginx/var/log/nginx/error.logSame path
Apache/var/log/apache2/error.log/var/log/httpd/error_log
PHP-FPM/var/log/php8.3-fpm.log/var/log/php-fpm/

Replace 8.3 with the PHP version on your server: 8.3 on Ubuntu 24.04, 8.4 on Debian 13, and 8.5 on Ubuntu 26.04. PHP errors from a script often land in the web server's log instead; Nginx records them as "FastCGI sent in stderr". Follow a log live while you load the failing page in a browser:

sudo tail -f /var/log/nginx/error.log

A site can also have its own log, set by an error_log line in its Nginx server block or Apache virtual host. If one is set, read that first.

PHP Fatal Errors

Most 500 errors on PHP sites are fatal errors: a syntax error after an edit, a call to a function that does not exist, a plugin that needs a newer PHP version, or a missing extension. The log line contains PHP Fatal error and names the file and the line. Fix that line, roll back the last change, or disable the plugin it names.

In production, errors belong in the log, not on the page. In php.ini:

display_errors = Off
log_errors = On

Errors shown to visitors reveal file paths and code. Turn display_errors on only on a test copy of the site. Restart PHP-FPM after a php.ini change: sudo systemctl restart php8.3-fpm on Debian and Ubuntu, sudo systemctl restart php-fpm on AlmaLinux and Rocky Linux.

PHP Memory Limit

A log line saying that the allowed memory size was exhausted means a script reached memory_limit. Check the file PHP-FPM reads; on Debian and Ubuntu the command-line PHP uses a different php.ini, so php -i can show another value:

grep -n memory_limit /etc/php/8.3/fpm/php.ini   # Debian and Ubuntu
grep -n memory_limit /etc/php.ini               # AlmaLinux and Rocky Linux

Raise it in steps, for example from 128M to 256M, and restart PHP-FPM.

A Broken .htaccess File

On Apache, one wrong line in .htaccess returns a 500 for the whole folder. The error log names the line, often as an invalid command, which usually means the module behind the directive is not enabled. Rename the file to test:

mv .htaccess .htaccess.off

If the site loads, put the file back and correct the line, or enable the missing module, for example sudo a2enmod rewrite on Debian and Ubuntu. Check the configuration with sudo apachectl configtest before you reload Apache. Nginx does not read .htaccess files at all.

Permissions, Disk Space, and Loops

  • Files PHP cannot read: the PHP-FPM pool user (www-data on Debian and Ubuntu, apache by default on AlmaLinux and Rocky Linux) must be able to read the site. Folders 755 and files 644, owned by the site's user, is a safe pattern. Never use 777.
  • A full disk: sessions and cache files cannot be written. See how to check disk space in Linux.
  • Internal redirect cycles in Nginx: a rewrite or try_files rule that points back at itself ends in a 500, and the error log says so.

When folder permissions block the web server itself, the answer is usually a 403 instead; see 403 Forbidden in Nginx.

Confirm the Fix

curl -I https://example.com/page-that-failed

The first line should now show 200, or the redirect you expect, instead of 500. Keep tail -f running on the error log through a few minutes of normal traffic to make sure no other page fails. If the server answers 503 under load instead, see 503 Service Unavailable.

Was this answer helpful?
Loading...