Other 500High

HTTP 500 Error: How to Diagnose and Fix Internal Server Error

An HTTP 500 error occurs when the server cannot process a request. This article explains how to identify the exact cause through server logs and apply proven fixes for web servers, programming languages, and CMS applications.

Updated at March 4, 2026
20-40 minutes
Medium
FixPedia Team
Применимо к:Web servers: Apache 2.4+, Nginx 1.18+, IIS 10.0+Languages: PHP 7.4+, Python 3.8+, Node.js 14+CMS: WordPress 5.0+, Joomla 3.9+, Drupal 9.xHosting: with access to logs and configuration files

What is a 500 Error

Example of a 500 error

A 500 error (Internal Server Error) is a general HTTP response code indicating that the server encountered an unexpected condition and could not fulfill the request. Unlike 4xx errors, where the problem is typically with the client's request, the 5xx series points to a server-side failure. The user sees a standard message without details, while the exact cause is recorded in the logs. Common causes include:

  • Syntax errors in application code (PHP, Python, Node.js).
  • Insufficient permissions for files or folders for the web server.
  • Exceeding memory or execution time limits.
  • Incorrect web server configuration (Apache, Nginx, IIS).
  • Conflicts between plugins, modules, or libraries.
  • Database connection issues.

Step-by-Step Diagnosis and Fix

Step 1: Find Error Details in Server Logs

Logs are your primary source of information. Without them, you are operating blind.

  1. Identify your web server. Common log paths:
    • Apache: /var/log/apache2/error.log (Debian/Ubuntu) or /var/log/httpd/error_log (CentOS/RHEL).
    • Nginx: /var/log/nginx/error.log.
    • IIS: %SystemDrive%\inetpub\logs\LogFiles\W3SVC1.
    • On shared hosting, logs are often accessible via the control panel (cPanel → "Metrics" → "Errors").
  2. Find entries matching the error time. Example for PHP:
    [04-Mar-2026 14:30:22] PHP Fatal error:  Uncaught Error: Call to undefined function some_function() in /var/www/html/index.php:15
    Stack trace:
    #0 {main}
      thrown in /var/www/html/index.php on line 15
    

    Here it's clear: in index.php on line 15, a non-existent function was called.
  3. If logs are empty, enable detailed logging:
    • For PHP in php.ini: log_errors = On, error_log = /var/log/php_errors.log.
    • For Apache: LogLevel debug in the virtual host configuration.
    • For Nginx: error_log /var/log/nginx/error.log debug;.

💡 Tip: If you don't know where the logs are, create a test PHP file with <?php phpinfo(); ?> and find the error_log section. Or check the web server configuration: for Apache grep -r "ErrorLog" /etc/apache2/, for Nginx grep -r "error_log" /etc/nginx/.

Step 2: Check Recent Changes to Code or Configuration

A 500 error often appears after:

  • A CMS update (WordPress, Joomla, Drupal).
  • Installing a new plugin, module, or theme.
  • Editing .htaccess, nginx.conf, web.config.
  • Making changes to application code.

What to do:

  1. Restore from a backup created before the changes. If you don't have one:
  2. Manually roll back changes:
    • For WordPress: via FTP, rename the plugin folder (wp-content/plugins/plugin-namewp-content/plugins/plugin-name.disabled). If the error disappears, the problem is that plugin. Do the same for the theme (wp-content/themes).
    • For configs: restore the previous version from your editor's history or a backup.
  3. Check if the error is gone. If yes — look for the specific error in the rolled-back code (return to Step 1).

Step 3: Ensure Correct Permissions

Incorrect file permissions are a frequent cause of 500 errors, especially after migrating a site or changing hosts.

Standard permissions:

  • Files: 644 (-rw-r--r--).
  • Directories: 755 (drwxr-xr-x).
  • Owner: the web server user (e.g., www-data for Apache/Nginx on Debian/Ubuntu, apache on CentOS).

How to apply on Linux:

cd /var/www/html  # Navigate to the site root
sudo chown -R www-data:www-data .  # Replace www-data with your user
sudo find . -type f -exec chmod 644 {} \;
sudo find . -type d -exec chmod 755 {} \;

For Windows (IIS):

  1. Open the site folder properties → "Security".
  2. Click "Edit" → "Add".
  3. Enter IIS_IUSRS, click "Check Names".
  4. Set permissions: "Read & execute", "Read".
  5. Ensure IUSR also has "Read" permissions.

Step 4: Check and Increase Resource Limits

If logs show Allowed memory size of X bytes exhausted (PHP) or Maximum execution time of X seconds exceeded, you need to increase limits.

  1. Find php.ini:
    php --ini | grep "Loaded Configuration File"
    

    Or create an info.php with <?php phpinfo(); ?> and open it in a browser.
  2. Change parameters in php.ini:
    memory_limit = 256M      ; Was 128M or less
    max_execution_time = 60 ; Was 30 or less
    post_max_size = 32M      ; For file uploads
    upload_max_filesize = 32M
    
  3. Restart the web server:
    sudo systemctl restart apache2   # Apache
    sudo systemctl restart nginx     # Nginx
    sudo systemctl restart php-fpm   # If using PHP-FPM
    
  4. If you don't have access to php.ini (shared hosting):
    • For Apache: add to .htaccess in the site root:
      php_value memory_limit 256M
      php_value max_execution_time 60
      
    • For some hosts: create a user.ini in the site root with the same directives.

Step 5: Disable Plugins/Modules to Find Conflicts

If the error appeared after installing/updating a plugin in a CMS.

WordPress:

  1. Via FTP, rename the /wp-content/plugins folder to plugins.off. This disables all plugins.
  2. If the error disappears, rename it back and disable plugins one by one by renaming their folders (e.g., akismetakismet.off), until the error returns.
  3. Check the plugin's compatibility with your WordPress version.

Joomla:

  1. If you have admin access, disable all extensions via "Extensions Manager".
  2. If not, via FTP rename folders in /administrator/components/ and /components/.
  3. Check Joomla logs in /administrator/logs/.

Drupal:

  1. If Drush is available, run drush pm-disable --all.
  2. Otherwise via FTP rename module folders in /modules/ and /sites/all/modules/.

Step 6: Check Configuration Files for Errors

Errors in web server configs are a common cause of 500s.

Apache (.htaccess and configs):

  1. Check .htaccess syntax in the site root. Delete all lines and add them back one by one, checking for the error.
  2. Check the main config: sudo apachectl configtest. Output Syntax OK means it's correct.
  3. Ensure required modules are enabled: sudo a2enmod rewrite (if using SEO-friendly URLs).

Nginx (nginx.conf and files in sites-enabled):

  1. Check syntax: sudo nginx -t.
  2. Ensure there are no typos in location blocks, and proxy_pass (if present) points to the correct address (e.g., http://127.0.0.1:8000).
  3. Check permissions on files specified in root or alias.

PHP (php.ini):

  1. Open php.ini and check for syntax errors (missing quotes, semicolons).
  2. Ensure necessary extensions are enabled (e.g., extension=mysqli, extension=gd).
  3. Verify display_errors = Off on production (but log_errors = On).

Errors in .htaccess (Apache) or nginx.conf (Nginx) cause 500 errors.

Apache .htaccess file with a syntax error causing a 500 error

A syntax error in a .htaccess configuration file results in an Internal Server Error

Apache (.htaccess and configs):

  1. Check .htaccess syntax in the site root. Delete all lines and add them back one by one, checking for the error.
  2. Check the main config: sudo apachectl configtest. Output Syntax OK means it's correct.
  3. Ensure required modules are enabled: sudo a2enmod rewrite (if using SEO-friendly URLs).

Nginx (nginx.conf and files in sites-enabled):

  1. Check syntax: sudo nginx -t.
  2. Ensure there are no typos in location blocks, and proxy_pass (if present) points to the correct address (e.g., http://127.0.0.1:8000).
  3. Check permissions on files specified in root or alias.

PHP (php.ini):

  1. Open php.ini and check for syntax errors (missing quotes, semicolons).
  2. Ensure necessary extensions are enabled (e.g., extension=mysqli, extension=gd).
  3. Verify display_errors = Off on production (but log_errors = On).

Preventing 500 Errors

  • Regularly check server logs (weekly or after each update). Set up monitoring via Logwatch, Papertrail, or similar tools.
  • Test all changes in a staging environment before production.
  • Use a version control system (Git) for quick rollbacks.
  • Monitor resource limits: track memory usage (memory_get_usage() in PHP) and execution time.
  • Update software gradually: CMS core, plugins, libraries — one at a time, and only from official sources.
  • Configure a custom error page (e.g., ErrorDocument 500 /500.html in Apache) so users see a friendly interface, but do not disable logging.

F.A.Q.

Why does a 500 error occur and how can I identify the root cause?
What should I do if I don't have access to server logs?
What's the difference between 500, 502, and 504 errors?
How can I prevent a 500 error from recurring after fixing it?

Hints

Locate error details in server logs
Check recent code or configuration changes
Verify file permissions are correct
Check and increase resource limits
Disable plugins/modules to find conflicts
Verify configuration files are correct

Did this article help you solve the problem?

FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community