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.

A person looking at the internal components of an open desktop computer tower.

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.

A rack of web hosting servers with green and amber status lights in a data center.

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.

We use cookies so you can have a great experience on our website. View more
Cookies settings
Accept
Decline
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Who we are

Our website address is: https://zadic.net.

Comments

When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection. An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.

Cookies

If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year. If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser. When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed. If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website. These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue. For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Visitor comments may be checked through an automated spam detection service.
Save settings
Cookies settings