Design your way

Tuesday, February 14, 2017

The 500 internal server error is quite common on WordPress websites, and display on all pages because of problems happening in the file system that runs and powers the site.

In most cases, they are caused by corrupted root directories (where most WP files are stored), but there are a number of other hosting issues that can lead to them.

It is important to learn how to deal with this error, mostly because it is frustrating and causes your website’s traffic to drop unexpectedly.

The solutions, unfortunately, are not that straightforward and simple, and take a lot of troubleshooting steps, time, and patience. Nevertheless, we tried to summarize several simple solutions that will eliminate the need to hire professional assistance to deal with this issue.

How are 500 Errors displayed on the website?

  • 500 Internal Server Error
  • HTTP 500 – Internal Server Error
  • Temporary Error (500)
  • Internal Server Error
  • HTTP 500 Internal Error
  • 500 Error
  • HTTP Error 500
  • That’s an error

It is compulsory to back up your data

Regardless of the approach you’ll take to solve this issue, it is a good idea to backup the site to prevent losing data if something goes wrong.

All of the solutions we are about to discuss will require you to change settings in the root directory, which is why it is better to prevent damage.

Checking error logs

It doesn’t matter if you’re dealing with 500 or any other WP error – you should always check the PHP and Apache error logs on the server to make sure nothing is corrupted there.

Plus, these logs help you define what type of code failure caused your website to go down, and consequently provide hints on how to solve the problem.

If working with a Linux server, you can locate the site’s main error log as:

/var/log/httpd/error_log

Owners of multiple sites hosted on a single server should have in mind that they all have individual error logs, all to be found inside the Apache configurations. In most cases, they are placed in the following directory:

/logs/ directory

The longer the error log is, the more challenging it will become to depict the right line, so in case you know the exact name of the problematic script, use this command to search for it:

more /var/log/httpd/error_log | grep [file name]

Instantly, all files named like this will be listed to your attention.

In case you’re not really sure which file to look for, try following the log in a separate window as it is being generated. Use this command in the SSH session:

tail -f /var/log/httpd/error_log

Keep the SSH session open and running, and open the web browser to refresh the problematic page, and to see whether 500 is still there. If it is, it will also appear in the log file.

Check the last ten lines from the error log using the following command:

tail -20 /var/log/httpd/error_log

Now that you know which file is causing the error, you can copy-paste its name on Google and look for helpful solutions.

Corrupted .htaccess files

Most of the time, 500 errors are caused by 2 specific problems: You have either exceeded the PHP memory limits of your website, or you’re working with a corrupted .htaccess file.

The reason why files become corrupted is the installation of a problematic plugin or other recent changes you’ve done on your website. In both cases, you can fix the issue easily: what it takes is to replace that file with a new one.

On the other hand, experiencing PHP memory limit problems means that you’re using too many plugins on the website, or have unfortunately installed such that are poorly coded and cannot handle the growth of your traffic’s website. In both cases, you’ll go beyond the memory limit given by your hosting provider, and 500s will appear on your pages to warn you about it.

How to replace the .htaccess file? Go to WinSCP or FIleZilla to locate the file and delete it. Next, visit the WP admin area, open the Settings section, and choose Permalinks. Go to the bottom of that page and save the changes you’ve made. In case the error is still there, other steps would be to test and increase the given PHP memory.

How to increase your WordPress PHP Memory limits

It is wrong to assume that hosting providers are the only ones limiting our PHP memory, as this is more frequently done by ourselves or by WordPress.

In case you’re beginning to exceed PHP memory, WordPress will react and try to increase it, but it can’t go beyond the thresholds imposed by your host. If you are sharing your server, those limits can be even lower.

In that case, it will be up to you to increase the memory, and then refresh the website to see whether it was the limit that was causing 500 errors to appear.

How can you do this? Go to the root directory and find the wp-config.php file. Once there, right-click on it, and download it on your device. Then, open it in a text editor by choice, and paste the following code below the first PHP tag:

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

Save it like that, go back to the directory, and upload it to overwrite the original one. Refresh both the client and the site, and check whether the error is still there. If yes, PHP memory limits were not the cause of your problem, so go back to the original wp-config.php file and upload it back inside the directory.

Plugin deactivation

If the solutions we discussed didn’t work in your case, it might be the time to check plugins and see whether it is one of them that is affecting your website’s performance. It may be a single one or even few of them that don’t play well with each other.

The more plugins you’ve installed, the more difficult and time-consuming it will be to detect the problem, which is why we recommend you to access it deactivating all of them at once.

After you’ve done this, the 500 error should disappear from your pages. Take your time, and reactivate one at a time to see which the problematic plugin that caused the error is. Don’t hesitate to delete it, and contact the author to report the problem.

Re-uploading core files in the root directory

Doing this should always be your last resort, worth a try only when none of the previously mentioned solutions seems to work. What it means is that you need to backup all website data, download a newer, fresh WordPress version, and install it.

Open the ZIP file saved on your device, and extract the files that are inside. Open the root directory via your FTP client, and upload the new wp-includes and wp-admin files to overwrite older versions. Then, refresh both the client and the site, and check whether the error is gone. Unfortunately, if a core file is not what caused the error, you should consider contacting the host for support.

Timed out PHP connections

Owners of PHP scripts that establish external network connections should also have in mind that some of those connections may have timed out.

It usually happens when there are too many connection attempts at once, and the system suffers a 500 error trying to prevent them. In order to avoid such problem, you need to readjust the codes in your PHP script and include session time-out rules.

Generally, it is very difficult to catch time outs while trying to connect to external databases or remote resources (RSS feeds, for instance), as they freeze the script and prevent it from running before notifying you that there is a problem.

Even before you’ve experienced a 500 internal error, try to remove some of the external connections that are not that important, as in such way you will accelerate loading and improve the overall performance of your website.

Contacting the host

Once you’ve tried all of our suggestions but none of them worked, the hosting provider is the only one that can solve your problem.

The reliability and quality of the support you’ll receive depends on the hosting services you’re using, meaning that some of you should seriously consider the possibility of their host shrugging the problem off, and putting blame on your files rather than the server. In some of the cases they will even be right, because they have no access to all plugins and themes that you’ve used on your website.

This is why it is critical to try all local solutions and then explain the host that there is no nook in the file system or an internal error that could cause the website to stop running.

Conclusion

500 internal server errors don’t only affect our website’s performance, but also frustrate us because of not having a clear cause or a solution. One needs to take the long mile to define the issue and then do plenty of troubleshooting, but with all steps listed an explained, this may not be as difficult as you think.

What is definitely a smarter idea is to keep the website in a good condition, and prevent such errors from happening in the first place. A good way to do that is to keep the WP version, core files, and plugins updated, or to make sure that the theme you’re using is compatible with other widgets and website elements.



Source: http://ift.tt/2lFAZ0u

No comments:

Post a Comment

 

The Cash Box Blueprint

Most Reading