Skip to main content

One post tagged with "web_servers"

View All Tags

500 Internal Server Error: what causes it and how to fix it

· 5 min read
Customer Care Engineer

how-to-fix-500-internal-server-error-website-troubleshooting

A 500 Internal Server Error is one of the most common issues website owners and administrators encounter. It signals that something went wrong on the server—but offers no precise diagnostics. This article explains what typically triggers a 500 error and how you can resolve it.


Possible causes of a 500 error

A 500 error can arise for many reasons. The most frequent are:

  1. Server-side resource issues

Often error 500 can be caused by technical problems on the server, such as lack of resources (RAM, CPU time).

  1. Errors in the website code

Scripts or website code may contain errors that cause a crash. This can be due to incorrect requests, errors in configuration files, or problems with the interaction of site components.

  1. Problems with the .htaccess file

The .htaccess file is used to configure the web server and may contain errors that will result in a 500 error. For example, incorrect redirect rules or incorrect parameters can cause a crash.

  1. Recent updates

Errors can occur after updates to the website or server applications where changes were not handled correctly.


How to fix a 500 error

  1. Check the web-server logs

To determine the cause of a 500 error, the first step is to check the server logs. These logs typically contain information about the failure — whether it's a code error, misconfiguration, or a server-level issue. However, it's important to understand that web server logs (such as those from Nginx or Apache) often only record the occurrence of the error and the response code, not the root cause. This is especially true for Nginx, which usually acts as a proxy and simply forwards the error from the backend application.

Depending on the web server being used, logs may be located in the following directories:

Apache:

  • Ubuntu/Debian: /var/log/apache2/error.log

  • CentOS/AlmaLinux/Rocky Linux: /var/log/httpd/error.log

Nginx:

  • /var/log/nginx/error.log

If your server is managed through a control panel such as FASTPANEL, viewing logs becomes even easier. To do this:

  • Log in to the control panel.

  • Open the site card and locate the “Logs” section.

  • The “Frontend Error Log” tab contains Nginx web-server errors, while the “Backend Error Log” tab contains Apache errors.

Keep in mind that many CMSs and frameworks (WordPress, Laravel, Joomla, etc.) maintain their own error logs. These logs often provide more precise information about the cause of a 500 error. Consult your platform’s documentation to find where these logs are stored.

Logs will very likely give you detailed insight into what went wrong. If the 500 error is triggered by misconfiguration or code issues, you can see the files—or even the exact lines—that cause the failure.

  1. Enable PHP-side error logging

To obtain more detailed diagnostics, enable logging directly in PHP—especially useful when the error originates in code and does not appear in web-server logs.

To do this, set the following values in the php.ini file:

display_errors = Off

log_errors = On

error_log = /var/log/php_errors.log

Here:

  • display_errors — suppresses error output in the browser

  • log_errors — writes errors to a log file

  • error_log — path to the log file (PHP must have write permissions)

Typical  php.ini locations:

  • Debian/Ubuntu: /etc/php/*/apache2/php.ini or /etc/php/*/cli/php.ini

  • CentOS/AlmaLinux: /etc/php.ini

Or locate it via:

php -i | grep "php.ini"

In FASTPANEL: open the site card → “PHP Settings”, search for variables such as display_errors, change their values, and click "Save". 

  1. Check the .htaccess file

If the error appeared after editing .htaccess, revert the file to its previous state.

If you are not sure what exactly has changed, temporarily rename .htaccess (for example, to .htaccess.bak) - if the error disappears, then the problem is in this file.

In this case, try to restore the .htaccess file from a backup if available, or use the default .htaccess file for your CMS, which you can get from here.

  1. Verify file permissions and ownership

Improper permissions can trigger a 500. Ensure the site root and all sub-files have correct rights and owner:

ls -laR /path/to/your/site/root

Recommended permissions:

  • For directories: 755 — read, write, and execute for the owner; read and execute for everyone else.

  • For files: 644 — read and write for the owner; read-only for everyone else.

Ownership:

Files and folders should belong to the web-server user (e.g.,www-data or apache).

If necessary, you can adjust permissions and ownership by using the following commands:

  • Change to your site’s root directory:
cd /path/to/root/directory/site
  • Set the correct ownership and permissions:
sudo chown -R yoursiteuser:yoursiteuser . && sudo chmod 644 . -R && sudo chmod +X . -R

Please replace yoursiteuser with the actual user and group that own your site.

  1. Disable plugins and themes.

For CMS-driven sites such as WordPress, a 500 error often arises from plugin or theme conflicts. Disable all plugins and switch to a default theme to see whether this resolves the issue.

  1. Make sure the server has sufficient free resources for your sites.
  • Check that you have enough free disk space:
sudo df -h
  • Check that the server has not run out of inodes:
sudo df -ih
  • Check that the server has enough RAM:
sudo free -mh
  • Check current CPU load:
sudo ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head
  • Alternatively, open the process monitor with the command:
sudo top

If you have run out of disk space or inodes, you can identify which files and directories consume the most space by following the instructions in the relevant article.

If RAM or CPU load is excessively high, the causes may vary. Start your investigation by blocking search-engine bots, as they are frequently the source of elevated load. 

  1. Verify that the DBMS is healthy.

Most often this will be MySQL; below are several quick steps to check whether your databases are OK. 

  • Confirm that the MySQL service is running:
sudo systemctl status mysql
  • Check the MySQL error log:
sudo grep -i error /var/log/mysql/error.log
  • Check all databases for errors:
mysqlcheck -A -c

If errors are found, first be absolutely sure you have backups of the affected databases. If needed, create a dump with:

mysqldump -u [user] -p [database_name] > /path/to/file/dump.sql
  • Replace [user] with the MySQL username.

  • Replace [database_name] with the name of the database you want to export.

  • /path/to/dump.sql  is the path where the dump file will be saved.

After that, run the error correction procedure with mysqlcheck:

mysqlcheck -A --auto-repair -c
  1. Contact your hosting provider.

If you are unable to identify the problem, it may be worth contacting your hosting provider's support. It can help identify problems on the server that are not visible at the user level. You can learn about how to choose the right hosting provider in this article.


Conclusion

Error 500 is not a verdict for your website. With the help of basic diagnostic tools, you can quickly find out the cause and fix the problem. If you are not confident in your abilities, you can always turn to specialists. It is important to remember that error 500 found and fixed in time will help you avoid more serious problems in the future.