Blog > Search Engine Optimization > How to Diagnose and Fix an Internal Server Error

How to Diagnose and Fix an Internal Server Error

Published by James ParsonsSearch Engine Optimization • Posted July 26, 2015
Written by ContentPowered.com

Websites and computers are fraught with issues. If you’ve ever had your computer come up with the Blue Screen of Death, you know what I’m talking about. Most people, when confronted with that error screen, just shut their machines down and take them to the nearest geek they know. Some of us are those geeks, and know how to read the information on the screen, and what to do about it. Did you know that different lines of code on that screen mean different things, and those codes indicate what error caused the computer to crash?

It’s not just operating systems and hard crashes that plague the computerized world. The Internet is, literally, nothing more than a massive collection of individual machines and lines connecting them, all running on a decades-old infrastructure with protocols that don’t always know how to handle everything that’s going on. Sometimes, when an error comes up, it’s a problem with a connection or a computer. Sometimes it’s a configuration error, or an error with a server.

One of the most common errors is the Internal Server Error.

There are a whole bunch of names you might see this under; 500 Internal Server Error, HTTP 500 Error, and more. It’s all the same thing, but you can only fix it if you’re the owner of the website and you’re capable of accessing and configuring said server.

When You See It

Example Error 500

The pesky part of the 500 Internal Server Error is that it can show up at any time and for any user. It doesn’t matter what operating system your users or your server is running, nor does it matter what device the user is using to browse. It can come up at any time.

The primary problem with diagnosing this error is what it means.

“Internal Server Error”? It’s really nothing more than “an error happened with the server.” There’s not really any information tied to the error message, at least not always. Sometimes, the server configuration gives a little extra indicator of the culprit, usually when the server is running a Microsoft IIS platform. You might see “500.19 – Internal Server Error” or something of that sort. In this case, the .19 is an indicator of what actually caused the error.

User Solutions

htaccess Example

If you’re a user encountering this error on a website you know otherwise works, there are a few options you can try. They don’t always work, because the 500 error is almost always a server error, but in the rare case that a client-side issue occurs, you could fix it with one of these methods.

  • Try resetting your .htaccess file. Your .htaccess may have some new code that is breaking your website.
  • If you’re using WordPress, try resetting your permalinks. This fixes a lot of 500 and 404 errors.
  • Comment out any new code you’ve added. It may be the culprit of the error.
  • Disable any new plugins you’ve added. These may be the culprit of the error.
  • Make sure that the URL for the page is correct. Sometimes, if you’re trying to copy and paste a long URL, you can cut off some characters at the end. By attempting to reach a page that doesn’t exist, you may trigger this 500 Internal Server Error. More likely you’ll be redirected to a 404 page, but if that kind of generalized redirect doesn’t exist on the server, this is the error you’ll get.
  • Try reloading the page. In some rare cases, it’s a flaw in communications rather than a flaw with the server that causes the error you see. Use your favorite method to refresh the page, like your browser refresh button, pressing F5 on your keyboard, or entering the URL again.
  • Try clearing your browser cache. Website caching typically puts files that it doesn’t expect will change onto your computer with an expiration date. If a file isn’t set to expire for 10 days, but the website changes them around, you won’t load the website properly and it will error out. Sometimes a forced refresh will fix this, while other times you need to delete cached files. Ideally, however, the site owner will configure their caching to push updates to changed files regardless of cache expiration dates.
  • Try deleting browser cookies. This is really just a good general tip to troubleshooting any Internet issue. Cookies will very, very rarely be the cause of an Internal Server Error, but most of the time you can just do it to eliminate it as the root cause. If it solves the issue, good!
  • Try treating it as a 504 error instead. A 504 error Is a bad gateway error, that usually occurs when an intermediary server isn’t responding properly. You can follow these steps to troubleshoot it.

Unfortunately, as a user, virtually none of this is going to work. A 500 error is almost always a server-side error, and that means there’s not much you can do. If it’s just one page on a site, try using a cached version of it from Wayback Machine or Google. If it’s an entire website, the whole thing is probably down and site owner will need to address the issue. You can use Down For Everyone Or Just Me to check if the site is down in general or if it’s an issue with your computer.

One thing you might consider is trying to contact the owners of the site, particularly if the error is just on a single page. They might not know about the issue, and you informing them will help them get to work on fixing it.

Steps as Site Owner

File Permissions

If you’re the site owner, and you’ve been informed that your site is presenting Internal Server Errors to people, you have some work to do. Unfortunately, until the issue is fixed, no one will be able to use your website. Business is effectively dead in the water.

There are three primary root causes of the 500 Internal Server Error.

  • Permissions. The majority of the time, the error that’s causing the 500 error to appear is incorrect permissions on a file or folder that is crucial to the functioning of your website. This is almost always caused by a script with incorrect permissions.
  • PHP Timeouts. PHP scripts are very useful in web design, but they often need to call functions or data from outside sources. For example, if you’re relying on data from a third party provider like Amazon Web Services or Akamai, and their server is non-responsive, the script will time out while waiting for that server to respond. This causes it to report back that it couldn’t access critical data, and thus the whole thing shuts down. This can be fixed with better timeout rules or error handling, though that’s not always possible with your scripts.
  • .htaccess Errors. The .htaccess file is a permissions file that requires proper structure to function. It’s also part of basically every CDN including WordPress, and thus is a very common cause of 500 server errors.

So how do you diagnose and fix these errors?

The first thing you need to do is determine if you’re running a content management system, like WordPress or Joomla. If so, good! You’ll be able to look into the specific steps for that CMS in order to fix the issue. I’ll give you an example of that later.

If you’re not using an off-the-shelf CMS like WordPress, you’ll probably want to talk to your web host. Dreamhost, Bluehost, Hostgator, 1&1; they all have instructions in their help centers to help you troubleshoot and fix a 500 Internal Server Error. If you can’t figure it out on your own, they probably have live support you can talk to via phone or web chat in order to find the cause of the error.

If you’re a coder and you’re using a CGI script or a Perl script, you’re going to want to troubleshoot it first. This is typically caused by syntax errors.

For some servers, a CGI script will need more than just an execute permission to run. It will also need ownership from the correct user and the correct group. This will vary from server to server, so try checking if you have another active CGI script that works, and copy the permission it has.

Microsoft IIS Errors

IIS Example

I mentioned before that when your server is running in a Microsoft IIS environment, it will produce more tangible information for the errors that come up with a 500 server issue. I’ll list what these are here.

  • 500.0 – Module or ISAPI error occurred.
  • 500.11 – Application is shutting down on the web server.
  • 500.12 – Application is busy restarting on the web server.
  • 500.13 – Web server is too busy.
  • 500.15 – Direct requests for Global.asax are not allowed.
  • 500.19 – Configuration data is invalid.
  • 500.21 – Module not recognized.
  • 500.22 – An ASP.NET httpModules configuration does not apply in Managed Pipeline mode.
  • 500.23 – An ASP.NET httpHandlers configuration does not apply in Managed Pipeline mode.
  • 500.24 – An ASP.NET impersonation configuration does not apply in Managed Pipeline mode.
  • 500.50 – A rewrite error occurred during RQ_BEGIN_REQUEST notification handling. A configuration or inbound rule execution error occurred.
  • 500.51 – A rewrite error occurred during GL_PRE_BEGIN_REQUEST notification handling. A global configuration or global rule execution error occurred.
  • 500.52 – A rewrite error occurred during RQ_SEND_RESPONSE notification handling. An outbound rule execution occurred.
  • 500.53 – A rewrite error occurred during RQ_RELEASE_REQUEST_STATE notification handling. An outbound rule execution error occurred. The rule is configured to be executed before the output user cache gets updated.
  • 500.100 – Internal ASP error.

Now, if your eyes glazed over when you read all of that, don’t worry; mine did too. I’m not an IIS certified IT professional, so I don’t know what most of that means. If you see one of those more specific errors, hand the issue over to your IT guy and let them figure it out.

If you don’t have an IT guy, or you’re determined to figure it out on your own, you can read more about the errors here. Just scroll down to “Common HTTP status codes and the causes” for more detailed information about each code.

cPanel Issues

PHP Version

Before we begin with fixing the error in WordPress, you need to know that the most up to date versions of WordPress – in other words, the ones you should be using to avoid security errors – need to be set to use PHP version 5.4 or higher. If your server is configured to use an older version of PHP, it will cause 500 errors. This is generally just a way for WordPress to prevent users from reaching a site filled with security exploits and issues.

Most web server environments will be running cPanel as the control panel software for things like PHP and WordPress. It’s in this panel that you change the version of PHP.

  1. Log in to your cPanel account.
  2. Click the PHP Configuration button, which will be in the Software/Services section. If you can’t find it, you should send a support message to your web host, as they might block it on older versions of server architecture.
  3. Select the version of PHP you want to use from the list of provided installations. If you don’t see anything 5.4 or higher, contact your web host to figure out why they won’t update, or to be given instructions on how to update your own local architecture.
  4. Click the update button to save the configuration.

WordPress Error Fixing

PHP Memory Limit

If you’re experiencing the issue with an Internal Server Error on WordPress, the first thing you need to do is check for a corrupted or invalid .htaccess file. The easiest way to do this is to log into your server via FTP and find the .htaccess file. Rename it – don’t delete it! – and try to load your site. If it works, your .htaccess file is causing the Internal Server Error.

If .htaccess was to blame, you’ll want to generate a new one. Go into your WordPress control panel and go to the Settings section. Find Permalinks and click the save button there. This will generate a new .htaccess file, and the old one can be safely removed.

The second most common cause in WordPress for the Internal Server Error is running into the PHP memory limit. This can happen if the limit is low, or if you have a lot of PHP running, or it’s running with a memory leak. You can experiment to discover if this is the issue by increasing the memory limit. This is pretty easy; just go to your wp-config.php file and open it up. You’ll look for the main PHP tag. Inside it, add

  • Define(‘WP_MEMORY_LIMIT’, ‘64M’);

Now save it and test to see if you still get the error. If you do, either the problem is caused by something else, or the memory limit didn’t take. It’s possible that your web host will need to change their php.ini file to remove the limit. Contact them about the issue.

If you have access to that php.ini file, all you need to do is add the line memory=64MB to the file, and upload it to the wp-admin folder. Again, test your site, and see if it works.

If it works, you’ve found that the memory limit is the cause, but you haven’t fixed the problem. Something, like a poorly created script or a memory leak, is eating up your available memory. Try disabling plugins to see if one of them is causing the issue, or talk to your web host and ask them if there’s anything in server logs that indicates the cause.

If the PHP memory limit didn’t fix it, do the typical WordPress diagnostic step of removing all of your plugins temporarily. If your site works with no plugins, then one of the plugins – or the interaction between two of them – is causing the problem. Enable them one by one until you find the one that breaks your site, and ditch it.

If, after all of this, you still haven’t fixed the problem, you might have some core file corrupted. Get a fresh WordPress install and copy over the wp-admin and wp-includes folders. This will save your information and settings, but will replace WP files that have been changed or corrupted, to hopefully fix any problem.

If your site is still down after all of this, there may be something wrong with the physical hardware of your web host. Contact them and try to troubleshoot the problem.

There are other causes of the error, both on and off WordPress. That’s really the problem with such a pesky, generic error; it’s difficult to troubleshoot. Ideally, one of the steps above has solved it for you. If not, you’re going to need to talk to your IT guy and your web host, and see if they can access any more specific server logs to help you identify the cause. Good luck!



Comments

Questions for us? Comments? Thoughts? Leave a reply!

Leave a reply

Share48
Tweet
Pin
Buffer
48 Shares