Website errors · Article 0137
How to Fix a 500 Internal Server Error on a Website
A 500 Internal Server Error means the server encountered an unexpected condition and could not complete a request. It does not identify the underlying cause. The problem may involve PHP code, server configuration, a damaged .htaccess file, resource limits, application exceptions, or an upstream service. The safest solution is to examine the evidence and correct the specific failure.
What does a 500 Internal Server Error mean?
HTTP status code 500 is a generic server error response. It indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
Unlike a 404 Not Found response, which indicates that the requested resource could not be found, a 500 response does not identify a single specific problem. The application or server may know what failed internally, but the public response usually does not reveal those details.
A 500 error can affect the entire website or only one page, form, API endpoint, or administrative function. It can also appear intermittently when a server is under heavy load or when a particular request triggers an application failure.
The first diagnostic task is to identify which request failed and match its timestamp with the relevant server or application log.
Common causes of HTTP 500 errors
1. PHP fatal errors
A PHP syntax error, unavailable function, incompatible dependency, or unhandled exception can prevent a PHP application from completing a request. The PHP error log may identify the affected file and line number.
2. Incorrect .htaccess configuration
On Apache servers, an invalid directive, malformed rewrite rule, unsupported configuration option, or incorrect .htaccess syntax can cause an internal server error. The Apache error log often identifies the problematic file or directive.
3. Incorrect file or directory permissions
Web server processes need appropriate access to website files and directories. Incorrect permissions or ownership can prevent scripts from running or files from being read. The correct values depend on the hosting environment, so avoid applying broad permission changes.
4. PHP memory exhaustion
A script may consume more memory than the configured PHP limit allows. This can happen during large imports, complex operations, plugin execution, or inefficient application code. Check the error log for a memory exhaustion message before changing the limit.
5. Incompatible plugins or themes
On WordPress websites, an updated plugin or theme may conflict with another component or with the installed PHP version. A fatal error can occur before the page is rendered.
6. Broken deployment or incomplete file upload
An interrupted update, incomplete deployment, or accidental file modification can leave application files missing or inconsistent. Compare the affected files with the last known-good version.
7. Database or application failures
An application may return a 500 response when a database operation, external API request, or internal processing step fails unexpectedly. The error log is needed to determine whether the database or another service is involved.
8. Hosting resource limitations
CPU limits, PHP process limits, memory restrictions, disk exhaustion, or server-level failures can prevent requests from completing. A hosting provider may need to inspect resource metrics and server logs.
Step 1: Identify the scope of the error
Before editing files or changing server settings, determine how much of the website is affected.
- Open the exact URL that returns the 500 error.
- Open the homepage and one or two other internal pages.
- Test whether the WordPress dashboard or application administration area is accessible, if applicable.
- Check whether forms, login requests, API endpoints, or other specific functions also fail.
- Record the approximate time, time zone, affected URL, browser, and response details.
- Repeat the test in a private browser window or from another network if practical.
Interpret the results carefully:
- Only one page fails: Investigate that page's application code, template, database query, or associated plugin.
- Every page fails: Investigate server configuration, application startup, PHP failures, and hosting resources.
- Only administrative functions fail: Inspect the relevant admin request, authentication process, and application logs.
- The error appears intermittently: Check resource usage, application timeouts, server processes, and upstream dependencies.
Step 2: Check the server error log first
The server error log is usually the most useful starting point because the public 500 response does not explain the underlying failure.
Depending on the hosting provider and server configuration, the log may be available through:
- The hosting control panel's Errors or Logs section.
- An
error_logfile in the website's document root. - An Apache error log.
- An Nginx error log.
- A PHP-FPM error log.
- A managed application or hosting diagnostic dashboard.
For a self-managed Nginx server, a commonly used error-log location is:
/var/log/nginx/error.log
For Apache, the location depends on the operating system and server configuration. The hosting provider may use a custom log path.
- Open the relevant error log.
- Locate entries matching the time when the 500 response occurred.
- Look for fatal errors, permission failures, configuration errors, or resource-limit messages.
- Record the first relevant error and any request identifier.
- Compare the log entry with the affected URL and recent website changes.
Do not assume that the first visible error in a large log belongs to your request. Match the timestamp and request information whenever possible.
Step 3: Check recent website changes
If the error began after an update, deployment, or configuration change, compare the current environment with the last known-good version.
Review recent changes such as:
- PHP version upgrades or hosting configuration changes.
- New or updated plugins and themes.
- Application code deployments.
- Changes to
.htaccessor server configuration. - Database migrations or schema changes.
- New security rules, firewall settings, or proxy configuration.
- Changes to environment variables or external service credentials.
If the error log identifies a recent change as the likely cause, test a rollback on staging first. If a production rollback is necessary, restore only the confirmed faulty change and retain a backup of the current state.
Step 4: Investigate the .htaccess file on Apache servers
If your website runs on Apache and the error log points to .htaccess, inspect that file for syntax problems or unsupported directives.
Common issues include:
- A malformed rewrite rule.
- An invalid directive or unsupported option.
- A directive that is not permitted by the server's AllowOverride configuration.
- An incomplete configuration edit.
- Rules copied from another hosting environment that are not compatible with the current server.
Test the file safely
- Open the website's document root through your hosting File Manager or secure FTP connection.
- Locate the existing
.htaccessfile. - Download or copy it as a backup.
- If the error log points to this file, temporarily rename it to a backup name such as
.htaccess-backup. - Reload the affected URL and compare the result.
- If the error disappears, inspect the original file and correct the specific invalid directive or rule.
- Restore the corrected configuration and test the affected URLs again.
If the website uses Nginx without Apache, .htaccess is generally not the configuration file controlling Nginx requests. Investigate the active Nginx server configuration instead.
Official reference: Apache .htaccess documentation.
Step 5: Check PHP errors and application code
If the server log points to PHP, investigate the exact error before editing the application.
Look for messages such as:
PHP Fatal errorUncaught ErrorParse errorAllowed memory size exhaustedFailed opening requiredCall to undefined function
These messages indicate different problems. For example, a parse error may identify invalid PHP syntax, while a missing-file error may indicate an incomplete deployment or incorrect file path.
- Identify the file and line number mentioned in the log.
- Inspect the relevant code and recent modifications.
- Compare it with the last known-good version.
- Check whether the required PHP extension or dependency is installed.
- Check whether the code supports the active PHP version.
- Correct the identified issue and test the same request again.
Do not replace an entire application file simply because it appears in an error message. First establish what failed and whether the file itself is the cause.
Step 6: Investigate WordPress plugin and theme conflicts
If the affected website uses WordPress and the logs point to a plugin or theme, isolate that component rather than disabling everything immediately.
If the WordPress dashboard is accessible
- Open Plugins → Installed Plugins.
- Identify the plugin associated with the error or recent update.
- Deactivate that plugin temporarily.
- Reload the affected page.
- If the error disappears, investigate the plugin's compatibility and available updates.
- Repeat with another component only if the evidence supports further testing.
If the dashboard is unavailable
- Back up the website files.
- Open
wp-content/plugins/through the hosting File Manager or secure FTP. - Locate the plugin identified by the error log, if known.
- Temporarily rename only that plugin's directory.
- Test the affected page.
- Restore the directory name or install a corrected version after the investigation.
Renaming a plugin directory may deactivate it. Check important website functions after recovery, especially forms, payment processing, membership features, and other plugin-dependent workflows.
If the error points to the active theme, test with a compatible default theme on staging when possible. Preserve the original theme files and check the website's appearance and functionality after the test.
Step 7: Check file permissions and ownership
Incorrect permissions or ownership can prevent the web server or PHP process from reading application files or accessing required directories.
Inspect the permissions of the affected file and its parent directories. Common shared-hosting configurations may use values such as 755 for directories and 644 for files, but the correct settings depend on the server's user model and security configuration.
Check for:
- Files that cannot be read by the web server process.
- Directories that cannot be traversed.
- Incorrect ownership after an upload or migration.
- Files with unexpectedly restrictive or overly permissive settings.
- Application directories that need write access but are not writable by the intended process.
Step 8: Check PHP memory and hosting resource limits
If the log reports memory exhaustion or process limits, investigate the resource usage associated with the failed request.
Check:
- The configured PHP memory limit.
- Whether a particular script or plugin consumes unusually large amounts of memory.
- Whether PHP-FPM has reached its configured worker or process limit.
- Available disk space and account storage limits.
- CPU and execution-time restrictions imposed by the hosting plan.
- Whether the error occurs only during large imports, backups, or other resource-intensive tasks.
Increasing a resource limit may help when the application legitimately needs more capacity and the hosting plan permits it. However, it will not correct inefficient code, an infinite loop, or an application defect.
Ask your hosting provider to inspect resource metrics if the relevant limits are not visible in your control panel.
Step 9: Check database and external service failures
Some applications return a 500 response when a database operation or external service request fails unexpectedly.
If the logs indicate a database problem:
- Check whether the database service is running.
- Confirm that the application is using the correct database configuration.
- Check the database server's error log and connection limits.
- Review whether a recent migration or schema change failed.
- Confirm that the application account has the required database privileges.
If the logs indicate an external API or service failure, check the provider's status information, request timeout, authentication response, and application error handling.
Do not reset the database or change credentials without evidence that the database connection is responsible. A generic HTTP 500 response alone does not prove a database problem.
Step 10: Check the reverse proxy or CDN layer
Websites using a reverse proxy, CDN, or load balancer may have several layers between the visitor and the application server.
Determine which layer generated the 500 response by checking:
- The response headers and any request or trace identifier.
- The CDN or proxy dashboard logs.
- The origin web server's access and error logs.
- The application logs for the same timestamp.
- Whether direct origin testing is supported by the hosting provider.
If the CDN reports an origin error, investigate the origin server rather than repeatedly changing browser or DNS settings. If the origin logs show no matching request, ask the proxy or hosting provider to trace the request through its infrastructure.
How to verify that the 500 error is fixed
After applying a correction, repeat the exact request that originally failed. Then test related functions to ensure the change has not created another problem.
- Open the original affected URL.
- Confirm that the response is successful and the expected content is displayed.
- Test the homepage and several important internal pages.
- Check login, forms, administrative functions, and APIs where applicable.
- Review the error log for new entries matching the test time.
- Confirm that the application can connect to its required database and external services.
- Check that temporary diagnostic settings and test configuration changes have been removed or restored.
- Repeat the test after clearing only the relevant cache if cached error responses are suspected.
A successful homepage response alone does not prove that every application function has recovered.
Common mistakes to avoid
- Assuming every 500 error has the same cause: The status code is generic. Use the logs to identify the actual failure.
- Changing several settings at once: This makes it difficult to identify which change affected the result.
- Deleting .htaccess immediately: Back it up and test only when the evidence points to Apache configuration.
- Setting all permissions to 777: This can expose files and create security problems.
- Increasing PHP memory without checking logs: Resource changes may hide an application problem rather than solve it.
- Disabling every plugin or security feature: Isolate the component responsible for the failure.
- Reinstalling the application too early: Reinstallation may not resolve server configuration or resource problems.
- Displaying debugging information publicly: Error messages may expose internal paths and sensitive implementation details.
- Ignoring intermittent failures: A website that works once may still have resource, concurrency, or upstream problems.
If the problem continues
Contact your hosting provider or application vendor when the error log is unavailable, the server configuration cannot be changed safely, or the failure continues after the evidence-based checks.
Provide the support team with:
- The exact affected URL.
- The approximate failure time and time zone.
- The HTTP status code and browser response.
- Any request ID or trace identifier.
- A sanitized error-log excerpt.
- Recent deployments, plugin updates, PHP changes, or configuration modifications.
- The tests already performed and their results.
Ask the provider to identify whether the error originates from Apache, Nginx, PHP-FPM, the application, a database, or another upstream service. This is more useful than requesting a broad server reset.
Never send administrator passwords, private keys, database passwords, or authentication tokens in an ordinary support request.
Frequently asked questions
What is the most common cause of a 500 Internal Server Error?
There is no single cause that applies to every website. PHP errors, invalid server configuration, resource exhaustion, incorrect permissions, and application failures are all possible. The relevant server or application log is needed to identify the cause.
Can a .htaccess file cause a 500 error?
Yes. On Apache servers, invalid directives, malformed rewrite rules, or unsupported configuration options in .htaccess can cause a server error. Check the Apache error log before changing the file.
Can a WordPress plugin cause a 500 Internal Server Error?
Yes. A plugin can trigger a PHP fatal error or conflict with another component. If the logs point to a plugin, isolate it safely and test the affected request again.
Does a 500 error mean my website has been hacked?
No. A 500 response does not establish that a website has been compromised. It can result from ordinary application, configuration, or resource problems. Investigate security indicators separately if there is evidence of unauthorized activity.
Why does my website show a 500 error only sometimes?
Intermittent failures can involve resource limits, PHP process availability, application timeouts, database connection limits, or an unstable external dependency. Compare successful and failed request times with server and application logs.
Can clearing the browser cache fix a 500 error?
Usually, clearing the browser cache does not repair the server-side cause of a 500 response. It may help rule out a cached response or local browser issue, but the underlying server or application failure still needs investigation.
Should I reinstall WordPress to fix a 500 error?
Not as the first step. Check the server logs, PHP errors, .htaccess configuration, and recent plugin or theme changes first. Reinstallation is appropriate only when evidence shows that application files are damaged and a controlled repair is necessary.
Related troubleshooting guides
- How to Fix a 502 Bad Gateway Error
- How to Fix a 503 Service Unavailable Error
- How to Fix a 504 Gateway Timeout Error
- How to Fix the WordPress White Screen of Death
- Browse all troubleshooting guides