Monday, February 7, 2011

How do I fix a ‘500 Internal Server Error’ on my website?

Interference with an .htaccess file

If you have implemented .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 configurations to ensure that it doesn’t contain any errors.
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.

PHP Coding Timing Out

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 such time outs and errors, we suggest that your relevant 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 as 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. You can use the following web-based tool (where is the member name assigned to your account – please check your Netfirms Welcome Letter for your membername; is the name of the script you are attempting to run):

CGI Script Guidelines:

  1. When editing your CGI script, use 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.
  2. Upload your CGI scripts in ASCII mode into the cgi-bin directory.
  3. 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. Using FileZilla, enter 755 under numeric value.
  4. If you are still getting errors, you can instruct the server to display any errors messages to the web browser by adding the following line near the top of the Perl script:
    1#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser);
  5. Double-check any changes you have made to the script and also ensure the following line appears after the Perl path:
    view sourceprint?
    1print "Content-type: text/htmlnn";
  6. Ensure that the Perl modules you require for your script is supported on the Netfirms Hosting plPn. For a list of the currently supported Perl modules, please click here.
  7. If your website is driven by Joomla, some third party components may result in a “500 Internal Server error.” To confirm this, login to your web account and location the components folder and then rename it. Then visit your Joomla website. If the error disappears, then this confirms one or more Joomla components are causing the error. You can test activating/renaming components folders until you determine which one(s) is problematic.