DB / Nginx/Apache/Web Servers / 500
CRITICAL

Nginx/Apache/Web Servers Internal Server Error

A generic HTTP status code indicating the server encountered an unexpected condition that prevented it from fulfilling the request. It is a server-side error, not a client issue.

Common Causes

  • Application runtime error (e.g., unhandled exception in PHP, Python, Node.js).
  • Misconfiguration in web server (Nginx/Apache) or application server (Gunicorn, uWSGI).
  • Exceeded resource limits (memory, execution time, file descriptors).
  • Permission errors on critical files or directories.
  • Database connection failures or timeouts.

How to Fix

1 Check Server and Application Logs

The primary diagnostic step. Examine the web server error log and the application's log file for the specific error message and stack trace.

BASH
$ # Check Nginx error log tail -f /var/log/nginx/error.log # Check application log (example for a common location) tail -f /var/log/app/error.log

2 Verify File Permissions and Ownership

Ensure the web server user (e.g., www-data, nginx) has read and execute permissions on the application directory and files.

BASH
$ # Fix permissions for a typical web directory sudo chown -R www-data:www-data /var/www/myapp/ sudo find /var/www/myapp/ -type d -exec chmod 755 {} \; sudo find /var/www/myapp/ -type f -exec chmod 644 {} \;

3 Increase Resource Limits

If the error is due to timeouts or memory exhaustion, increase the limits in your PHP/Python configuration or web server.

BASH
$ # Example: Increase PHP memory limit and execution time # Edit php.ini or a pool .conf file memory_limit = 256M max_execution_time = 120

4 Restart Application Services

Restart the web server and application processes to clear any transient state or crashed workers.

BASH
$ # For systemd with Nginx and Gunicorn sudo systemctl restart nginx sudo systemctl restart myapp-gunicorn