Base de Conhecimento

How to Fix the 500 Internal Server Error on Your WordPress Website Print

  • 0

The 500 internal server error runs on every page of your site when there’s a problem with the server or file system that’s powering your site. The cause most likely occurs in the root directory, where your WordPress files are, but it can also be caused by a problem on your host’s server.

This is one of the most frustrating errors that can occur in WordPress. It never has a straightforward solution, requiring a lot of troubleshooting that can eat up your time and patience. But we’re going to try to help alleviate some of that stress by suggesting several solutions to this problem and walking you through each.

Let’s get started.

Backing Up Your Site

These solutions require making a lot of changes in your site’s root directory. It’s highly recommended you backup your site prior to trying any of these solutions in case something goes wrong.

Using an FTP Client

If you already have experience using an FTP client, skip this section. I’m going to go over how to set up an FTP client for those who have never used one as most of these solutions require it.

An FTP client allows you to access and edit your site’s files. You can use the File Manager your host uses, of course, but an FTP client of your choosing is often easier to use.

download-filezilla

There are many FTP clients, but we’re going to use FileZilla for the purpose of this demonstration. Go to FileZilla’s homepage, and click Download FileZilla Client.

Click the green Download FileZilla Client button if the site is recommending your exact operating system. If it’s not, click the Show Additional Download Options link beneath the green button and download the version that’s appropriate for your operating system.

Open the client once you’ve downloaded the installer and have installed it on your system. Click File > Site Manager. Click New Site, and enter your site’s name.

filezilla-ftp-setup

Configure these settings:

  • Host – Your domain name
  • Port – Leave blank
  • Protocol – FTP – File Transfer Protocol
  • Encryption – Only Use Plain FTP
  • Logon Type – Normal

Use the username and password you use to access your host’s file manager. If your host uses cPanel, use the login information you use to access cPanel. If you’re not sure, ask your host.

Go to the Transfer Settings tab, and select the checkbox for Limit Number of Simultaneous Connections. Set the Maximum Number of Connections to 8. This keeps your site’s server from blocking your IP address. Click Connect to connect to your site’s server.

You’re ready to go!

Common Solutions for the 500 Internal Server Error

The two most common causes of this error are a corrupted .htaccess file and exceeding your server’s PHP memory limit. The .htaccess file in your WordPress directory can become corrupted after you install a plugin or make another change to your WordPress site. The fix is simple. All you need to do is create a new .htaccess file.

PHP memory limit issues often occur as the result of a poorly-coded plugin running on your site or a site that’s grown considerably over time and is using too many plugins. You’ll begin to exceed the PHP memory limits set by your hosting provider once either of these things happen. The result is a 500 internal server error.

We’re going to learn how to create a new .htaccess to get rid of the corrupted one as well as how to test whether or not you’re exceeding your PHP memory limits.

Creating a New .htaccess File

Open your WordPress root directory in FileZilla or your preferred FTP client. This is typically called public_html. If you see folders named wp-admin and wp-content, you’re in the right place. If you don’t see your .htaccess file or any dotfiles, make hidden files viewable by clicking Server and selecting Force Showing Hidden Files.

rename-htaccess-file

Once you find your .htaccess file, right-click it, and rename it “.htaccess.bak”. This essentially deletes your site’s .htaccess file, so we need to create a new one. Go into your WordPress admin area. Hover over Settings, and select Permalinks. Scroll down to the bottom of the page, and click Save Changes.

Open your website in your browser. If the 500 internal server error is gone, it was caused by a corrupted .htaccess file and your issue is now fixed. If you’re still seeing the error, you have some more tests to run.

It’s also worth mentioning that an improperly named .htaccess file will cause this error to run on your site. Make sure this file is not named anything other than “.htaccess”.

Increasing Your PHP Memory Limit in WordPress

PHP memory limits are set by your host and WordPress. WordPress will attempt to increase your limit if you begin exceeding it, but it can only go as high as the limit your host has placed on your server. This limit is often lower for shared hosting plans. You need to increase your PHP memory limit in WordPress and refresh your site to test whether or not this is causing your 500 internal server error.

wp-config-php-file

Open your root directory, and locate your wp-config.php file. Right-click on the file, and select Download to download it to your computer. Open the file in your preferred text editor, and add this bit of code under the opening PHP tag:

define('WP_MEMORY_LIMIT', '64M');

Save the file, and re-upload it to your root directory, overwriting the original file. Refresh the client, and refresh your site. If you still see the error, you are not having PHP memory limit issues. Remove the above code from the wp-config.php file on your computer, save it, and re-upload it to your root directory.

Don’t get too excited if you don’t see the error. You still have some work to do.

Increasing your site’s PHP memory limit in the wp-config.php file is the equivalent of pouring bleach down your kitchen sink when it smells like rotten eggs. You’re fixing the problem well enough to get rid of the offensive odor, but you’re not fixing the bigger issue at hand, which is likely a clog somewhere in the pipes that lead to your sink.

The same is true with increasing your site’s PHP memory limit. You may have increased it yourself in the file, but something is still exhausting your limit. You can follow the steps in the next few sections to try and find out what that might be, but if worst comes to worst, you’ll likely need to convince your host to increase the limit on your server.

Less Common Solutions for the 500 Internal Server Error

Fixing a corrupted .htaccess file and increasing a site’s PHP memory limit are the top two solutions for fixing this error, but there are other solutions if those haven’t helped you.

They are as follows:

  • Deactivating plugins to check for faulty plugins.
  • Locating issues by debugging your site.
  • Checking if your files and folders have the correct file permissions.
  • Uploading fresh wp-content and wp-includes folders to your site.
  • Asking your host if the issue is on the server that powers your site.

Deactivating Plugins

deactivate-plugins

If you’re able to access the WordPress admin area, deactivate your plugins one by one. Refresh your site after each deactivation. If the error disappears, it was likely caused by the plugin you deactivated prior to refreshing.

Delete the plugin and find a replacement if its function is important for your site. If you don’t feel you can replace the plugin, contact the developer directly. You can do this within the plugin’s support forum on WordPress.org, but I recommend doing a bit of research to see if the developer offers support elsewhere.

If you cannot access the WordPress admin area, open your FTP client. Open the root directory, and open the wp-content folder. This folder contains your Plugins, Themes and other folders.

rename-plugins-folder

Rename the Plugins folder to anything you wish, such as “plugins.test”. This deactivates all of the plugins on your site. Refresh your site. If the error is gone, it was caused by a faulty plugin. Activate each plugin one by one, refreshing your site after each activation, to find out which plugin is causing the error.

Make sure you rename the folder back to “Plugins” afterward.

Debugging Your WordPress Website

debugging-wordpress

If you’re having trouble figuring out what’s causing this error to run on your site, you may want to use WordPress’ built-in debugging feature. Pasting a bit of code into your site’s wp-config.php file enables debugging on your site. Any errors found are recorded in a file in your directory.

Josh Pollock wrote a post on how to use this feature in WordPress a while back. If you’re a developer, go ahead and start debugging your site. If you’re an average site owner, you may want to sit this one out as you may not know the difference between a minor error that can be safely ignored and a major error that should be taken care of promptly.

Normally, debugging a live site is frowned upon as it may reveal essential code to site visitors, among other things. However, it may be the only thing that explains what might be causing the 500 internal server error to run on your site.

Checking File Permissions

check-file-permissions

This likely isn’t the issue, but it’s still worth checking. In your WordPress directory, permissions for folders and files should be 755 or 644. Setting permissions to anything else may cause problems, including 500 internal server errors.

Open your root directory in an FTP client. Many clients, including FileZilla, have a Permissions tab you can use to quickly check the permissions for each file and folder in your root directory. Make sure these are not set to anything other than 755 or 644.

Uploading Fresh Versions of wp-admin and wp-includes to Your Site

This step should be a last resort, but if you’ve used the above solutions and still cannot find one that works, it’s worth a try. Backup your site, and download a fresh version of WordPress from the main site.

wp-admin-wp-includes-folders

Extract the files from the ZIP file, and open the extracted folder. Open your site’s root directory in an FTP client, and upload the wp-admin and wp-includes from your fresh version of WordPress to your site’s directory, overwriting the older versions.

Refresh the client, and refresh your site. If the error is gone, it was likely caused by a corrupted core file


Esta resposta lhe foi útil?
Back