The error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
indicates a server-side issue, commonly caused by misconfigured .htaccess files, PHP errors, file permission issues, or server configuration problems.
The first step in diagnosing the issue is checking the error logs.
sudo tail -f /var/log/apache2/error.log # Debian/Ubuntu
sudo tail -f /var/log/httpd/error_log # CentOS/RHEL
sudo tail -f /var/log/nginx/error.log
Identify the specific cause of the error before proceeding with fixes.
A corrupted .htaccess file is one of the most common causes of 500 Internal Server Errors.
mv /home/user/public_html/.htaccess /home/user/public_html/.htaccess_backup
sudo systemctl restart apache2
If your site is WordPress-based:
If the error is PHP-related, check the PHP logs.
Edit the wp-config.php file:
nano /home/user/public_html/wp-config.php
Add or update:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
Error logs will be stored in wp-content/debug.log.
For Apache:
sudo tail -f /var/log/apache2/php_errors.log
For PHP-FPM:
sudo tail -f /var/log/php8.0-fpm.log
Fix any PHP syntax errors or missing extensions.
Incorrect permissions can prevent the server from accessing files.
find /home/user/public_html -type d -exec chmod 755 {} \;
find /home/user/public_html -type f -exec chmod 644 {} \;
For Apache:
chown -R www-data:www-data /home/user/public_html
For Nginx:
chown -R nginx:nginx /home/user/public_html
Restart the web server after applying changes:
sudo systemctl restart apache2
sudo systemctl restart nginx
If your site requires more memory, increase PHP limits.
sudo nano /etc/php/8.0/apache2/php.ini # Apache
sudo nano /etc/php/8.0/fpm/php.ini # Nginx
memory_limit = 512M
max_execution_time = 300
upload_max_filesize = 128M
post_max_size = 128M
sudo systemctl restart php8.0-fpm
sudo systemctl restart apache2
If the error persists, the issue may be with the web server configuration.
sudo apachectl configtest
If errors appear, fix them in:
sudo nano /etc/apache2/apache2.conf
Restart Apache:
sudo systemctl restart apache2
sudo nginx -t
If errors appear, edit:
sudo nano /etc/nginx/nginx.conf
Restart Nginx:
sudo systemctl restart nginx
| Issue | Fix |
|---|---|
| Corrupt .htaccess file | Rename it & regenerate via WordPress |
| PHP errors | Enable debugging in wp-config.php & check logs |
| File/folder permission issues | Run chmod 755 for directories, chmod 644 for files |
| Memory limits exceeded | Increase memory_limit in php.ini |
| Apache/Nginx misconfiguration | Run apachectl configtest or nginx -t |
Now your website should work without an Internal Server Error!