To fix a 500 internal server error on a PHP website, read the error log, identify the failing file, and correct the cause. The browser's message is generic, but the real error message usually gives you a starting point.
We recommend making one change at a time so you can see what works. Start with a backup, then follow the evidence.
Key Takeaways
- Reproduce the failure and read the matching PHP or server error log entry.
- Show errors only in development. Keep production details private.
- Match the fix to the message before changing memory, permissions, plugins, or hosting plans.
1. Protect Your Files Before Troubleshooting
Make a full backup of your website files and database before editing anything. Keep a copy outside the hosting account.
Then identify the last change. A deployment, plugin update, PHP switch, or .htaccess edit gives us a useful first suspect. Restore the previous working version if that safely brings the site back.
Use a code-aware editor such as Notepad++ rather than Microsoft Notepad. Syntax highlighting makes missing quotes and brackets easier to spot.

Avoid repeatedly submitting a failed checkout or payment request. The transaction may have completed before the response failed.
2. Reveal the Hidden PHP Error
A 500 response means the server couldn't complete the request. It doesn't prove PHP caused it; server configuration can fail before PHP runs.
Enable error display in development
On a development server, temporarily enable debug mode by setting display_errors = On and error_reporting = E_ALL in the active php.ini.
For script-level debugging, place ini_set('display_startup_errors', '1'); and error_reporting(E_ALL); immediately after the opening PHP tag. PHP's error reporting documentation explains the reporting levels.
These calls can't expose a parse error that prevents the same file from executing. Startup failures may also happen before runtime settings take effect.
Keep production details in logs
Reproduce the failure once and note the time, then check the matching PHP error log first. If PHP may not have started, inspect the server error logs.
Look for an error_log file in the script's directory or an Errors section in your hosting control panel. Common server locations include /var/log/apache2/error.log and /var/log/nginx/error.log. PHP-FPM may have a separate log.
On a live site, keep display_errors = Off, log_errors = On, and error_reporting = E_ALL so production errors remain in logs. PHP's error configuration reference covers these controls.

3. Find the Exact Point of Failure
We want the error type, file path, and line number. Those details turn a blank page into something you can fix.
Read the message and stack trace
A fatal error containing Call to undefined function curl_init() points to unavailable cURL support. Enable the curl extension for the website's PHP runtime, then repeat the failing request.
A stack trace shows the chain of calls leading to the failure. Start with the reported error location, then follow the first relevant application frame. Don't edit a library simply because its filename appears in the trace.
For background requests, open browser developer tools, select the Network tab, repeat the action, and select the request showing status 500. Its Response tab may contain the fatal error if display is enabled.
Isolate code in development
Place die('OK'); immediately after <?php. Reload, then move it down section by section until the 500 returns.
The failure lies between the last successful position and the new one. Narrow that section further. This won't bypass a parse error in the same file.
Use this technique only in development, since it stops normal processing. Remove every diagnostic statement afterward.
4. Fix PHP Code, Extensions, and Database Access
Start with the category named in the log. Raising unrelated limits usually adds confusion.
Repair syntax and missing files
For a syntax error, undo the last edit or run php -l index.php against the affected file, using the matching PHP version. This checks syntax without executing the script.
Inspect the reported line and the line immediately before it. Missing semicolons, quotes, and brackets often surface later than the actual mistake.
For Failed opening required, restore the missing file or deployment dependency. Check filename capitalization and use __DIR__ where appropriate to make include paths independent of the working directory.
Restore modules and database connections
Check extensions against the runtime serving the domain, not just php -m. Command-line PHP can use different settings.
Typical PHP extensions include curl, mbstring, zip, mysqli or pdo_mysql, and openssl. Image tools may require imagick or gd. JSON support is bundled with PHP 8.0 and newer.
For could not find driver, enable the required database driver. For Access denied, correct the database credentials or grants. For Connection refused, investigate the database service, host, port, or socket.
Match a supported PHP version
Select a supported, compatible release in the hosting panel, such as PHP 8.3 or 8.4. Older advice to switch to PHP 8.1 or 8.2 needs context: PHP 8.1 is unsupported in November 2026.
If the error started immediately after a version change, temporarily restore the previous supported version. Update incompatible code before retrying the upgrade on staging.
5. Repair .htaccess and File Permissions
If PHP never starts, server configuration deserves attention.
On Apache-compatible hosting, rename .htaccess to .htaccess_old through SFTP, FTP, or File Manager. Reload the site. If it works, inspect the saved file for malformed rewrite rules or unsupported directives. Apache's rewrite troubleshooting guidance explains how rewrite logging helps.
For WordPress, go to Settings > Permalinks > Save Changes to regenerate the file when WordPress has write access. Preserve any needed custom rules separately.
Nginx doesn't process .htaccess, so this test doesn't apply to Nginx-only configurations.
For permissions, common starting values are 755 for folders and 644 for files. WordPress's wp-config.php commonly uses 640 or 644, depending on ownership and the server setup.
Never apply 777 as a shortcut. It creates security exposure, and some servers reject overly permissive files with a 500.
If permissions look correct but the log says Permission denied, have support repair ownership. Avoid broad recursive changes across the account.
6. Troubleshoot WordPress Without Losing Content
For WordPress, start with a useful debug log. Then isolate the component named in it.
Enable private WordPress logging
In wp-config.php, above the stop-editing comment, set define('WP_DEBUG', true);, define('WP_DEBUG_LOG', true);, and define('WP_DEBUG_DISPLAY', false);.
Edit existing definitions instead of adding duplicates. Reproduce the error, then read /wp-content/debug.log. The log must be writable for this to work.
A path under wp-content/plugins or wp-content/themes gives you a starting point. Protect logs from public access, remove them after troubleshooting, and switch debugging off when finished.
Isolate plugins, themes, and damaged core files
If the dashboard won't load, rename /wp-content/plugins to plugins_old to check for a plugin conflict. Test again. If the site returns, open the Plugins screen so WordPress records the missing plugins as inactive.
Restore the folder name and reactivate the plugins. Then deactivate plugins one at a time, repeating the failing action after each change. If plugins aren't responsible, temporarily activate an installed default WordPress theme.
Must-use plugins and drop-ins load separately, so renaming the regular plugins folder doesn't disable everything.
If logs point to damaged core files, replace wp-admin and wp-includes with clean copies from a fresh WordPress download matching the installed release. Leave wp-content and wp-config.php untouched.
After repairs, test login, forms, uploads, checkout, and connected services.
7. Address Memory and Hosting Limits
An Allowed memory size exhausted message means PHP reached its per-process memory limit. Start with the process or plugin named in the log.
For WordPress, set define('WP_MEMORY_LIMIT', '256M'); in wp-config.php. For general PHP, use memory_limit = 256M in the active php.ini or the hosting panel's PHP settings.
These values can't override your hosting account's hard limits. Our WordPress memory troubleshooting guide covers that distinction.
Shared hosting caps memory, processes, and CPU. Hitting those caps can produce 500 errors or other resource-related responses. Compare the failure time with your account's resource history using our cPanel resource usage guide.
On a VPS, the operating system's out-of-memory killer can terminate PHP or MySQL directly. Review kernel logs for killed processes before restarting services.
A larger memory limit can help a legitimate workload, but it won't repair an endless loop or broken query.
When the code is healthy but resource limits keep interrupting business, choose more capacity. Our cPanel hosting starts at $4.99/month; explore ZADiC hosting options for your site's next step.
Frequently Asked Questions
Is a 500 error my fault?
A 500 is a server-side failure, not usually a visitor's mistake. For site owners, the cause can be application code, configuration, permissions, or hosting resources. The response alone doesn't identify who caused it.
Is error 500 temporary?
Sometimes. A brief resource spike or restarting service may clear without a code change. A repeatable failure after the same action needs investigation. Refreshing won't repair broken PHP or an invalid server directive.
Where are PHP logs on shared hosting?
Start in the hosting panel's Errors or Logs area, then look for an error_log file near the failing script. Log locations depend on the domain's PHP handler and hosting configuration.
Get the Site Working, Then Keep It Stable
The fastest reliable fix starts with the exact error message. Correct its cause, repeat the failed action, and remove temporary debugging tools before reopening normal traffic.
If recurring limits are holding back an otherwise healthy site, explore our hosting plans. We offer 24/7 support so you have help when troubleshooting gets complicated.





