[SOLUTIONS] 500 Internal Server Error PHP

500 Internal Server Error is one of the common PHP errors that can put a PHP developer in panic mode. This article provides information on the most common causes. Why it become common PHP errors ? because you will found this error in WordPress, Prestashop, Codeigniter, Java, ASP.NET or whatever.

500 Internal Server Error is not a client side problem. It’s up to the sysadmin of the Web server site to locate and analyse the logs which should give further information about the error. Based on Wikipedia, 500 Internal Server Error is A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.

Here are several common ways that you might see the HTTP 500 error:

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

HOW TO FIX THE 500 INTERNAL SERVER ERROR

CHECK YOUR SERVER ERROR LOGS

With any error message, particularly one as broad as the 500 Internal Server Error, you will first want to check any Apache and PHP error logs for your server. These logs can provide valuable context related to any code failures or other potential causes of a site failure.

ERROR WITH AN .HTACCESS FILE

If you are using a .htaccess on your site, it may be interfering with the web page you are trying to load into your browser. Please double check the .htaccess configuration. Any syntax errors will cause a 500 Internal Server Error message to be displayed instead of your website.

To confirm whether a misconfiguration .htaccess is the cause of the 500 Internal Server error, either remove or rename the .htaccess file temporarily and then try to reload the page.

If your PHP script makes external network connections, the connections may time out. If too many connections are attempted and time out, this will cause a “500 Internal Server Error.” To prevent these time outs and errors, you’ll want to make sure that PHP scripts be coded with some timeout rules. Typically, however, catching a timeout error when connecting to a database or externally to remote resources (example: RSS feeds) are difficult. They, in effect, freeze the script from continuing to run.

Removing any external connections can increase both the performance of your website and decrease the chances of you receiving a “500 Internal Server Error.”

SYNTAX OR CODING ERRORS IN YOUR CGI/PERL SCRIPT

If it is a web page ending in .cgi or .pl that is producing the error, check your script for errors.

CGI Script Guidelines

When editing your CGI script, use a plain text editor – a program that saves the file as a ‘text file’ type. DO NOT use Wordpad that comes with Microsoft Windows because it doesn’t save files in pure ASCII text format. Use Notepad instead to edit files.
Upload your CGI scripts in ASCII mode into the cgi-bin directory.
Set the file permissions on the CGI script file and directories to be chmod 755. If you use an FTP program to transfer files, right-click on the file and select change file attributes.
Double-check that the Perl modules you require for your script is supported.

Troubleshoot as a 504 Gateway Timeout error instead.

It’s not very common, but some servers produce a 500 Internal Server Error when in reality a more appropriate message based on the cause of the problem is 504 Gateway Timeout.

Delete your browser’s cookies

Some 500 Internal Server Error issues can be corrected by deleting the cookies associated with the site you’re getting the error on. After removing the cookie(s), restart the browser and try again.

How To Fix the 500 Internal Server Error PrestaShop

There are two ways to turn on Error Reporting in PrestaShop depending on what version you have.

For PrestaShop v1.4 through v1.5.2

  1. Open config/config.inc.php
  2. On or around line 29 you will find this line
    @ini_set('display_errors', 'off');
  3. Change that line to read
    @ini_set('display_errors', 'on');

For PrestaShop v1.5.3+

  1. Open config/defines.inc.php
  2. On or around line 28 you will find this line
    define('_PS_MODE_DEV_', false);
  3. Change that line to read
    define('_PS_MODE_DEV_', true);

Once you enable error reporting through your FTP or CPanel, you can navigate back to your PrestaShop’s front or back office and reproduce the error or issue you are having. For example, if you are not able to access your website because of the 500 error, you will need to turn on error reporting and refresh the page(s) that had the error. There will be additional information that you can use to investigate the problem.

How To Fix the 500 Internal Server Error WordPress

Checking for Corrupt .htaccess File

The first thing you should do when troubleshooting the internal server error in WordPress is check for the corrupted .htaccess file. You can do so by renaming your main .htaccess file to something like .htaccess_old. To rename the .htaccess file, you will need to login to your site using the FTP. Once you are in, the .htaccess file will be located in the same directory where you will see folders like wp-content, wp-admin, and wp-includes.

Once you have renamed the .htaccess file, try loading your site to see if this solved the problem. If it did, then give yourself a pat on the back because you fixed the internal server error. Before you move on with other things, make sure that you go to Settings » Permalinks and click the save button. This will generate a new .htaccess file for you with proper rewrite rules to ensure that your post pages do not return a 404.

If checking for the corrupt .htaccess file solution did not work for you, then you need to continue reading this article.

Increasing the PHP Memory Limit

Sometimes this error can happen if you are exhausting your PHP memory limit. Use our tutorial on how to increase PHP memory limit in WordPress to fix that.

If you are seeing the internal server error only when you try to login to your WordPress admin or uploading an image in your wp-admin, then you should increase the memory limit by following these steps:

  1. Create a blank text file called php.ini
  2. Paste this code in there: memory=64MB
  3. Save the file
  4. Upload it into your /wp-admin/ folder using FTP

Several users have said that doing the above fixed the admin side problem for them.

If increasing the memory limit fix the problem for you, then you have fixed the problem temporarily. The reason why we say this is because there has to be something that is exhausting your memory limit. This could be a poorly coded plugin or even a theme function. We strongly recommend that you ask your WordPress web hosting company to look into the server logs to help you find the exact diagnostics.

If increasing the PHP memory limit did not fix the issue for you, then you are in for some hard-core trouble shooting.

How To Fix the 500 Internal Server Error Codeigniter

Check your error logs, sometimes the problem is with file permission, so make sure your file permission is 0755.

 

Read also:

[SOLUTIONS] 502 Bad Gateway Error on Nginx

[SOLUTIONS] 504 Gateway Timeout Nginx

 

Sources:

500 Internal Server Error – pcsupport.about.com
WHY AM I GETTING A 500 INTERNAL SERVER ERROR MESSAGE? – mediatemple.net
The 500 Internal Server Error Explained Solved

Related Posts

Finding a DropShipping Wholesaler

June 5, 2016

Tutorial

So now you are probably wondering how you can find and qualify a genuine wholesale drop shipper. You will need some patience and time to search through a drop shipper directory in order to find the best drop shipping companies for your particular product niche. There are many drop shipper directories available on the Internet, […]

Read More

AliExpress Dropshipping Plugin WordPress

Dropshipping is an good way to start an ecommerce business without needing to worry about inventory or shipping. It’s as simple as listing a product for sale on your website, and sending an email to your supplier to ship the item on your behalf whenever you get an order. While starting a dropshipping business is […]

Read More