How to Fix 500 Internal Server Error?
The internet for the frontend users may look simple, but it has complex environment at the backend. As a user, you may not be worrying much about the process happens at the backend. But if you have noticed, there are many error messages shown on the browser whenever there are problems in accessing a website. These are called HTTP status codes indicating the technical representation of the problem in the connectivity. A simple example is a “404 Page Not Found” error indicating the page you are trying to open is not available.
Similarly if you’ve found yourself confronted with a “500 Internal Server Error”, you’re probably wondering what it is and how to fix it.
What is 500 Internal Server Error?
Plainly speaking, an internal server error typically means that something, somewhere, has gone wrong on the web server. The formal definition of 500 internal server error is as below:
The 500 HTTP status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
Like most internet based errors, they can be seen on any browser, operating system or device that has access to the internet. The error message is shown differently on the browser based on the type of web server. Below is an example from the Apache server.
On other servers it may show messages like:
500 Internal Server Error
Sorry, something went wrong.
A team of highly trained monkeys has been dispatched to deal with this situation. Please report this incident to customer service.
Also, please include the following information in your error report: —
Usually, the problem has something to do with the web page, or the coding behind it, and is typically not on your end. However there are always couple of things that can be tried to fix this error.
Fixing 500 Internal Server Error for an User
1. Reload the Webpage
The first possible solution to the problem is just to simply reload the page on your browser. You can do this by clicking on the refresh button on the address bar.
Remember refreshing the webpage will try to resend the data to webserver. Hence, don’t refresh the page if you have filled up some forms like payment form. This is to avoid the form is submitted double time and the payment is also done double time.
2. Check the URL
Accessing inappropriate URL may also result in internal server error. So ensure to check the spelling of your URL is correct.
If you are accessing subdirectories, try going to the base URL of the site and see if you can go to where you were again. For example, if you were stuck on a page called “www.site.com/options/”, the base URL for the address would be “www.site.com”.
3. Clear Browser’s Cache
Failing that, you could attempt to clear the browser cache. A browser cache is essentially a storage place for all the related web data that you may have accumulated whilst visiting websites. Often when webpages are loaded frequently, or have been done so recently, the webpage will load back off of the browser cache, giving the semblance of having loaded again. For this reason, clearing the cache might cause the webpage to fully reload and potentially resolve the problem. Clearing browser’s cache or history may differ based on the browser you use. Generally this can be done through the browser’s settings page.
If you are using Google Chrome, go to the URL “chrome://settings/clearBrowserData”. Choose “Cached images and files” and click on the “Clear Browsing Data” button.
4. Clear Browser Cookies
Cookies are essentially little pockets of data that might relate to certain functions in a website. They are stored by the browser and used when required. Sometimes corrupted cookies can also cause the problem and result in internal server error. Though this is rate situation, no harm in trying to open the page after clearing the cookies on your browser.
While clearing your browser cache, ensure to choose the checkbox “Cookies and other site data”. Remember clearing cookies will sign out you form the logged in sites. You should log into those sites again.
5. Check the Site is Up
If the above still hasn’t done anything to fix the problem, then the problem could be that the site itself is down. Use one of the site up or down services and check the site you are trying to access is really down.
6. Contact Your ISP
If the site is up and only you get 500 internal server error, then probably some misconfiguration at your ISP could cause that. Check out with your service provider that everything is fine from his end.
7. Contact Site Owner or Administrator
If the site is down then it’s a good idea to inform the site owner about it. Generally the site owner’s email would be something like “email@example.com” or “firstname.lastname@example.org”. If you could not remember the site owner’s email, just send email to “email@example.com”. Most of the professional site owners use catch all email id. This means whatsoever the address you mentioned, all the emails will be forwarded to a specific id of their choice.
Beyond these options, you have to wait and just try to open the page later.
If You are a Website Owner or Administrator:
1. Check plugins and themes
As a site owner, you need to update plugins and themes of your website to keep them in a latest and secured version. This is especially true when you content management systems like WordPress.
There are many possibilities the PHP code on these plugins are resulting in a conflict and show 500 internal server error on the browser. So the first action you should do is to revert back the last action and downgrade the plugin or theme to it’s previous version. You should test the latest version in development site before applying the changes in production version.
2. Check Server Log
The web server will have a log file to record all the activities carried out by different users. This log file will be located in the root of your website with the name like “logs” or “error_log”. When you see internal server error, open the log file and try to understand what exactly is causing the error.
If you can’t access the error log or can’t understand the content, request your hosting company to analyze the error log file for you. It is important to get the root cause so that it will not repeat again affecting the live users.
3. Check File Permissions
Remember the correct file permission is important for a website to load properly on the browser. Generally file permission is applied at directory level which will be applied to all files in that directory. In this case, the directory with wrong file permission will lead to internal server error.
Let us take an example, we store images in a separate folder classified with yearly and then monthly. The folder 2017 has correct permission for read, write and execute. When the year ends, the new folder is created by default for 2018 which does not have execute permission for normal users. This resulted in the pages with the images from 2018 folder will show 500 internal server error while other pages will load normally.
If you could not guess or identify the file permission yourself ask help from the hosting company. Content management systems like WordPress has security plugins to check and apply correct file permissions for the complete site with a single click.
4. Check CDN and Caching
The other important aspect of websites is using content delivery network (CDN) and caching plugins in order to improve the page loading speed. Caching has different steps like combining scripts and stylesheets, passing the traffic to CDN servers or redirecting the traffic through different nameservers.
In all cases, there are lot of possibilities something can go wrong and the caching will result in server error. So if you have caching enabled and getting the 500 HTTP error then disable caching and then check the site is working fine.
5. 500 Internal Error Due to Scripts
The web server can only handle certain amount of load in terms of CPU and memory. You will see internal server error or one of the 5xx HTTP error codes, whenever the requested resource is triggering a script in the backend trying to overload the server.
Let us take an example, you have a dynamic XML Sitemap on your site triggered with PHP script. This Sitemap has thousands of URLs in a single file. Most of the servers will not have capability to show thousands of URLs in a single XML Sitemap file. This will result in showing server error when you try to open the Sitemap on the browser. Here you should split the Sitemap by reducing the number of URLs to avoid the error.
6. Due to Wrong Directives and Configurations
Ensure to play around with the backend files on your site with care. Leaving a single additional dot in those files will result in server configuration errors like internal server error. Below are some of the commonly accessed files where you can check for errors:
- Wrong directive entry in your .htaccess file
- Mistakes in theme’s functions file
- Error in server configuration file