500 Internal Server Error: What It Means & How to Fix It

The 500 Internal Server Error is an HTTP status code that indicates the web server encountered an unexpected condition and could not complete the request. It is a generic server-side error: the server knows something went wrong but cannot be more specific about the cause.
This guide explains what causes a 500 error, how to diagnose it using server logs, and the most common fixes for web servers like Apache and Nginx.
Quick Reference
| Cause | Fix |
|---|---|
| File/directory permission issue | find /var/www/html -type d -exec chmod 755 {} +, find /var/www/html -type f -exec chmod 644 {} +, then chown -R www-data:www-data /var/www/html |
.htaccess syntax error | Check syntax or temporarily rename the file |
| PHP error | Check /var/log/apache2/error.log or /var/log/nginx/error.log |
| Exhausted memory or disk | Check with free -h and df -h |
| Database connection failure | Verify credentials and service status with systemctl status mysql |
| Broken plugin or theme (CMS) | Disable recently updated plugins via CLI or file manager |
What Is an HTTP 500 Error
When you open a web page, your browser sends a request to the server hosting the site. The server processes the request and returns an HTTP response code along with the requested content. Response codes in the 200 range indicate success, while codes in the 500 range indicate a server error.
The 500 status code is the most general server error. The server returns it when no more specific error code (such as 502, 503, or 504) applies.

What Visitors Can Do
If you encounter a 500 error while browsing a website, the problem is on the server side, not with your browser or internet connection. You can try the following:
- Reload the page: The error may be temporary. Wait a few seconds and refresh.
- Clear your browser cache: If the error page is cached, your browser may keep showing it. Clear the cache and try again.
- Try a different browser or device: This helps rule out browser-specific caching issues.
- Come back later: The server administrator may already be working on a fix.
- Contact the website owner: If the error persists, let them know so they can investigate.
Common Causes and Fixes
If you are the server administrator, the following are the most common causes of a 500 Internal Server Error and how to fix them.
File Permission Issues
The web server process needs read access to your site files and execute access to directories. Incorrect file permissions are one of the most frequent causes of 500 errors.
To fix permissions for a typical web root:
sudo find /var/www/html -type d -exec chmod 755 {} +
sudo find /var/www/html -type f -exec chmod 644 {} +
sudo chown -R www-data:www-data /var/www/htmlReplace www-data with the user your web server runs as (e.g., nginx or apache).
.htaccess Syntax Errors
If you use Apache, an invalid directive or syntax error in the .htaccess file causes a 500 error. Common mistakes include typos, referencing modules that are not loaded, and incorrect rewrite rules.
To test, temporarily rename the file:
mv /var/www/html/.htaccess /var/www/html/.htaccess.bakIf the site loads after renaming, the problem is in the .htaccess file. Review it line by line or check the Apache error log for the specific directive that failed.
PHP Errors
A fatal PHP error (such as a syntax error, missing extension, or exceeded memory limit) causes the server to return a 500 error instead of rendering the page.
Check the PHP error log or the web server error log:
sudo tail -50 /var/log/apache2/error.logFor Nginx with PHP-FPM:
sudo tail -50 /var/log/nginx/error.logIf the error is a memory limit issue, increase the memory_limit value in the active php.ini file for your PHP runtime. First, find the loaded configuration path:
php --iniThen edit the appropriate php.ini file shown in the output:
sudo nano /path/to/php.iniFind the memory_limit line and increase it:
memory_limit = 256MRestart the PHP service after making changes.
Database Connection Failure
Web applications that rely on a database (MySQL, MariaDB, PostgreSQL) return a 500 error if they cannot connect. This can happen when the database service is down, credentials are wrong, or the database is corrupted.
Check whether the database service is running:
sudo systemctl status mysqlIf it is not running, start it:
sudo systemctl start mysqlVerify the database credentials in your application configuration file (e.g., wp-config.php for WordPress).
Broken Plugins or Themes
Content management systems like WordPress, Joomla, and Drupal can throw a 500 error after updating or installing a plugin or theme.
To diagnose, rename the plugins directory to disable all plugins at once:
mv /var/www/html/wp-content/plugins /var/www/html/wp-content/plugins.bakIf the site loads, re-enable plugins one at a time to find the one causing the error.
Server Resource Exhaustion
Running out of memory or disk space causes the server to fail when processing requests. Check available memory and disk space:
free -hdf -hIf memory is exhausted, identify the processes consuming the most memory:
ps aux --sort=-%mem | head -10If disk space is full, find and remove large unnecessary files, or clear log files that have grown too large.
Incorrect File Ownership After Deployment
After deploying files via SCP , rsync, or Git, the uploaded files may be owned by the wrong user. The web server process cannot read files it does not own.
Check the ownership:
ls -la /var/www/html/Fix it by setting the correct owner:
sudo chown -R www-data:www-data /var/www/htmlChecking Server Logs
The fastest way to determine the cause of a 500 error is to check the web server error log. The log file location depends on your distribution and web server:
| Web Server | Log Path |
|---|---|
| Apache (Ubuntu, Debian) | /var/log/apache2/error.log |
| Apache (Fedora, RHEL) | /var/log/httpd/error_log |
| Nginx | /var/log/nginx/error.log |
To view the most recent entries:
sudo tail -50 /var/log/nginx/error.logFor real-time monitoring while you reproduce the error:
sudo tail -f /var/log/nginx/error.logThe log typically contains the exact error message, the file path, and the line number that caused the failure.
Troubleshooting
500 appears after a deployment
Check ownership and permissions under the web root. Deployment tools often write files with the wrong user. Use ls -la to verify owner/group and correct them with chown and safe file/directory modes.
500 appears only on dynamic pages
This usually points to PHP or application-level failures. Check web server logs and PHP-FPM logs, then verify extensions, memory limits, and application configuration values.
500 appears after editing .htaccess
Temporarily rename .htaccess and test again. If the site starts working, restore the file and fix directives one section at a time.
No clear error in web server log
Enable more detailed application logging and reproduce the error while tailing logs in real time (tail -f). Also check service status with systemctl status for the web server, PHP-FPM, and database.
FAQ
Is a 500 error my fault as a visitor?
No. A 500 error is a server-side issue. There is nothing wrong with your browser, device, or internet connection. The server administrator needs to fix it.
What is the difference between 500, 502, and 503 errors?
A 500 error means the server encountered an unexpected condition. A 502 (Bad Gateway) means a reverse proxy received an invalid response from an upstream server. A 503 (Service Unavailable) means the server is temporarily overloaded or under maintenance.
How do I fix a 500 error in WordPress?
The most common causes are a broken plugin, a corrupted .htaccess file, or a PHP memory limit. Rename the plugins directory to disable all plugins, rename .htaccess to regenerate it, and increase the memory_limit in php.ini. If the page is blank instead of showing an error, follow our guide on fixing the WordPress White Screen of Death
.
Can a 500 error be caused by too much traffic?
Yes. If the server runs out of memory or worker processes due to high traffic, it returns a 500 error. Increasing server resources, enabling caching, or using a CDN can help.
How do I prevent 500 errors?
Monitor server logs regularly, set up alerts for error spikes, test changes in a staging environment before deploying to production, and keep software and dependencies up to date.
Conclusion
A 500 Internal Server Error means the server encountered a problem it could not handle. The most common causes are file permission issues, .htaccess errors, PHP failures, and database connection problems. Always check the web server error log first; it contains the specific error that triggered the 500 response.
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page