A 500 Internal Server Error means the web server encountered an unexpected problem while processing your request. Here's how to fix it.
Step 1: Check server error logs
The error log contains details about what went wrong. Log in to your hosting control panel and look for:
- Error log (often in cPanel under "Error Log" or "Logs")
- Access log (shows the timing and HTTP status of requests)
Common patterns in error logs:
[error] Premature end of script headers: index.php
[error] Allowed memory size exhausted
[error] Fatal error: Call to undefined function
[error] Parse error: syntax error in functions.php
If you find a specific error message with a file name and line number, note it—that's your starting point.
Step 2: Check file and folder permissions
Incorrect permissions prevent the web server from reading or executing your files.
- Web files and folders should be readable by the server (usually 644 for files, 755 for directories).
- Login to your hosting control panel or FTP client and check:
- Your public_html folder and its contents are set to at least 755 (folders) and 644 (files).
- If you're not sure how, use your control panel's file manager—look for "Permissions" or a right-click option.
Common permission problems:
[error] Permission denied opening index.html (file set to 600 or 400)
[error] Permission denied creating temp file (folder set to 644)
Step 3: Restart the web server
Sometimes a temporary process conflict causes a 500 error.
- Contact your hosting provider and ask them to restart Apache/Nginx or the PHP service.
- If you have server-level access, run:
```
sudo systemctl restart apache2
```
(or restart nginx if using Nginx)
Step 4: Check PHP memory limit and timeout
Large files or complex scripts can exhaust available memory or time limits.
- Log in to your control panel and look for "PHP Configuration" or "PHP Settings."
- Increase these values if they're very low:
- memory_limit: Set to at least 128M (or 256M if you're processing images/PDFs).
- max_execution_time: Set to at least 300 (seconds).
- upload_max_filesize: Match your file upload needs.
If you have access to php.ini, you can edit it directly:
memory_limit = 256M
max_execution_time = 300
upload_max_filesize = 100M
Step 5: Check .htaccess file
An incorrect .htaccess rule can cause 500 errors. This file controls URL rewriting and access rules.
- Via FTP or file manager, locate .htaccess in your public_html folder (it's hidden by default; enable "show hidden files").
- Check for syntax errors:
- Missing closing </IfModule> tags.
- Typos in directive names like RewriteEngie instead of RewriteEngine.
- Rewrite rules with incorrect syntax.
If you recently edited .htaccess and the 500 error started right after, try:
- Rename it temporarily (e.g., to
.htaccess.bak) to disable it. - Reload your site in your browser.
- If the site works, your
.htaccessis the problem. Review the recent changes. - If the site still shows 500, rename it back and check the other steps above.
Step 6: Check for database connection errors
If your site uses a database (WordPress, custom app, etc.), verify the connection details:
- Log in to your control panel and verify your database:
- Database name
- Database username
- Database password
- Database host (usually localhost)
- Confirm these match your site's configuration file (e.g.,
wp-config.phpfor WordPress, or your app's database config file).
- Check if your database is running by asking your hosting provider, or testing the connection through a tool like phpMyAdmin in your control panel.
Step 7: Check recent code or plugin changes
If you recently uploaded files or installed plugins/extensions:
- Disable any newly installed plugins (rename their folders temporarily so they don't load).
- Revert any code changes you made before the error started.
- Check the error log again after making changes to see if the error message changes.
When to contact your hosting provider
If the above steps don't resolve the issue, contact your hosting provider with:
- The exact URL that shows the 500 error
- When the error started
- Any recent changes you made (new plugins, file uploads, code changes)
- The relevant error message from your error log (copy and paste it)
- The steps you've already tried
A 500 error is a server-side problem, so your hosting provider may need to investigate server logs or your account configuration to help further.