keepcalculator

06 Numbers and Powers

How to Fix a 500 Internal Server Error on Your Web Server

Card No. 06·32109 · Updated · Standard formula, shown below

A 500 Internal Server Error is a generic message that means something went wrong on the server, but the server can’t specify what. It can affect any website, from a personal blog to a large e-commerce store. This guide walks you through the most common causes and fixes, from checking error logs to adjusting file permissions, so you can get your site back online quickly.

What You’ll Need

  • Access to your web server’s file system (via FTP, SSH, or your hosting control panel’s file manager).
  • Credentials to log into your hosting control panel (cPanel, Plesk, or similar).
  • If you use a content management system (like WordPress), admin access to the dashboard.
  • A text editor (like Notepad++ or Visual Studio Code) for editing configuration files.

Step-by-Step

  1. Refresh the page and try again. Sometimes a 500 error is transient—a temporary glitch or a timeout. Wait a few seconds and refresh. If it persists, move on.
  2. Check the server error log. This is the single most useful step. The error log will usually tell you exactly what file and line caused the problem. Access it via your hosting control panel (often under “Logs” or “Errors”) or via SSH (e.g., tail -f /var/log/apache2/error.log for Apache, or tail -f /var/log/nginx/error.log for Nginx). Look for the timestamp matching when you saw the error.
  3. Check file permissions. Incorrect file permissions are a common cause. Files should typically be 644 (read and write for owner, read for group and others), and directories should be 755 (read, write, and execute for owner, read and execute for others). Use your FTP client or file manager to set these. Be careful not to set files to 777 (world-writable) as that’s a security risk.
  4. Check the .htaccess file (Apache) or nginx.conf (Nginx). A syntax error in these configuration files can cause a 500 error. For Apache, try renaming .htaccess to .htaccess_backup and reload the page. If the error goes away, the problem is in that file. You can then restore it and edit it line by line to find the faulty directive. For Nginx, run nginx -t to test the configuration for syntax errors.
  5. Check for PHP errors. If your site runs on PHP, a fatal error in a script can trigger a 500 error. Enable PHP error reporting temporarily by adding these lines to your php.ini or at the top of your script:
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    This will display the actual error on the page, which you can then fix. Remember to disable it once resolved.
  6. Check the PHP memory limit. If your script exceeds the memory limit, you’ll get a 500 error. Increase the limit by editing php.ini (e.g., memory_limit = 256M) or via your hosting control panel. If you can’t access php.ini, you can try adding ini_set('memory_limit', '256M'); to your script, but that’s a temporary workaround.
  7. Check for corrupted .htaccess or wp-config.php (if using WordPress). A corrupted WordPress configuration can cause 500 errors. You can test by temporarily renaming wp-config.php to wp-config_backup.php and reloading—if you get a different error (like “Error establishing a database connection”), then the original file was fine. Restore it and move on.
  8. Check disk space. If your server’s disk is full, it can cause 500 errors. Check your disk usage via your hosting control panel or df -h in SSH. If it’s full, delete unnecessary files or upgrade your plan.
  9. Check for malware or hacked files. A compromised site can cause 500 errors. Scan your files for suspicious code, especially in index.php, .htaccess, and wp-config.php. If you find anything, replace the files with clean versions from a backup or reinstall the CMS.
  10. Restart your web server. Sometimes a simple restart clears the error. In your hosting control panel, look for “Restart” or “Stop/Start” for Apache or Nginx. If you have SSH access, use sudo service apache2 restart or sudo systemctl restart nginx.

Common Mistakes

  • Skipping the error log. Guessing without checking the log wastes time. Always start there.
  • Setting file permissions to 777. This is a security risk and often not the real fix. Use 644 for files and 755 for directories.
  • Editing .htaccess without a backup. Always back up before making changes, so you can revert if you break something else.
  • Not checking for syntax errors in configuration files. A single typo can cause a 500 error. Use a linter or test command (like nginx -t) before applying changes.

Tips

  • Always keep a recent backup of your site, so you can restore quickly if needed.
  • If you’re using a hosting provider, check their status page—the error might be on their side.
  • Use a staging environment to test changes before pushing to production.
  • Keep your CMS, plugins, and themes updated to reduce the risk of errors.

Troubleshooting

If you’ve tried the steps above and the error persists, here are additional things to try:

  • Contact your hosting provider. They may have server-level logs or can see issues that you can’t. Provide them with the exact URL and time of the error.
  • Check if the error is specific to one page or the whole site. If it’s only one page, the issue is likely in that page’s code or a plugin/function it calls. If it’s the whole site, it’s more likely a server-wide configuration or resource issue.
  • Disable plugins/themes (if using a CMS). Rename the plugins folder (e.g., to plugins_off) to see if the error disappears. If it does, re-enable them one by one to find the culprit.
  • Check for syntax errors in your main script. If you recently edited a PHP file, a missing semicolon or bracket can cause a 500 error. Use php -l filename.php to check for syntax errors.
  • Check the server’s system logs. In SSH, look at /var/log/syslog or /var/log/messages for any hardware or kernel issues.

Frequently Asked Questions

What does a 500 Internal Server Error mean?

It’s a generic error indicating the server encountered an unexpected condition that prevented it from fulfilling the request. It’s not specific—you need to check logs to find the root cause.

How do I find the error log?

Most hosting control panels have a “Logs” or “Errors” section. If you have SSH access, look in /var/log/apache2/error.log (Apache) or /var/log/nginx/error.log (Nginx).

Can a 500 error be caused by a bad plugin?

Yes, especially in WordPress. A plugin with a bug or a conflict can cause a 500 error. Disable all plugins and re-enable them one by one to identify the problem.

Is a 500 error the same as a 404 error?

No. A 404 error means the page doesn’t exist, while a 500 error means the server failed to process a valid request due to an internal issue.

Will clearing my browser cache fix a 500 error?

Usually not, because the error is on the server side. However, clearing your cache can help if you’re seeing a cached version of an error page. It’s worth trying, but the root cause is server-side.

How long does it take to fix a 500 error?

It depends on the cause. Simple issues like a syntax error can be fixed in minutes, while more complex problems like server misconfiguration might take longer. Using the error log will speed up the process.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →