Sometimes, an error in permissions or syntax within a script will result in an Internal Server Error 500, also known as an HTTP Error 500. But what does this mean, and how do you fix it?
Well, in order to fix an HTTP Error 500, you must first understand what it means to receive one.
What is HTTP Error 500?
An HTTP Error 500, is an error code that designates a general error within the server keeping it from processing users’ requests. This is usually related to an incorrect permission, a request timing out, or a coding error.
If you’re online visiting a website and receive a 500 error, there is usually little you can do to resolve it. Apart from contacting the webmaster and letting them know, chances are, the problem exists within the server hosting the site and is outside of your control.
But what if you’re receiving an Internal Server Error 500 on your own server or website?
Common Causes of Internal Server Error 500
As the HTTP Error 500 only denotes a general issue with the server, it is possible for multiple issues to cause a 500 error. If you’re not sure where to begin looking to diagnose the issue, you’ll probably want to start by checking your error logs. This can be done within your control panel under “Statistics -> Show Error Logs”.
The following are several of the more common causes of an HTTP Error 500 as well some basic troubleshooting solutions.
Bad Permissions, Writable by Group
This is probably the most common cause of an Internal Server Error 500. Typically it is caused by incorrect file permissions on a PHP or CGI script, but it may also be an issue with another file or directory used by the script.
Check and make sure that your directories and folders are set to 755 or rwxr-xr-x. Do not make your CGI scripts 777 (or rwxrwxrwx). Doing so would allow them to be editable by other users on the same server. Executable scripts within the cgi-bin folder should be 755. If your script contains password information for connecting to a MySQL database, you should make it and its directory’s permissions 700 (rwx– —). Images, media, and text files like HTML should be 644.
In the terminal, you can use the “ls -l” command to list the files in a directory alongside their permission settings. From there, you can use:
chmod +rwx filename
to add or change permissions on a file.
You might also want to determine if your script’s paths are set correctly. Start by verifying that the first line of your script is the path to Perl and that it is set correctly. It should be set to:
/usr/bin/perl
or
/usr/local/bin/perl
You should also verify that the scripts were uploaded in the correct mode (either ASCII or Binary). You can check the readme for the scripts to see if any special instructions are included. Typically, the correct mode will be ASCII.
For more information, check out our article on troubleshooting CGI scripts.
Bad .htaccess, Invalid Command
Within the (dot) htaccess file, it’s possible to receive an Internal Server 500 Error due to lines you may have added that are either worded badly or are conflicting in some way. The best way to troubleshoot this is to comment out the lines in the htaccess and determine by process of elimination which line or lines are causing issues.
*Note: It would be wise to save an original copy of any files you intend to edit before you start making changes.
You can comment out a line in the .htaccess by adding “# “to the beginning of it. For example, if the .htaccess looks like:
DirectoryIndex default.html
AddType application/x-httpd-php5 php
Then try something like this:
DirectoryIndex default.html
#AddType application/x-httpd-php5 php
Broken lines and lines that start with php_flag are the most common mistakes. If you cannot determine which line is the source of the problem, then comment out every line.
Exceeding Resources, Nothing in the Error Log
If the above two options yield no results, it is possible your 500 error is caused by too many processes in the server queue.
With SSH (shell) access, you can view the processes running on your account using the command:
ps faux
Or, type this to view a specific user’s account (be sure to replace username with the actual username):
ps faux |grep username
Once you have the process ID (“pid”), you can kill the specific process using the following command (be sure to replace pid with the actual process ID):
kill -9 pid
Popular Links
Looking for more information on Linux? Search our Knowledge Base!
Interested in more articles about Operating Systems? Navigate to our Categories page using the bar on the left or check out these popular articles:
- How to Check the Apache Version on a Linux Dedicated cPanel Server
- How to Change a Password in Linux
- How to Check if Your Linux Server is Under DDoS Attack
Popular tags within this category include: Linux, Windows, Apache, CentOS, Debian, Fedora, RedHat, and more.
Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.
The Hivelocity Difference
Seeking a better Dedicated Server solution? In the market for Private Cloud or Colocation services? Check out Hivelocity’s extensive list of products for great deals and offers.
With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.
Unsure which of our services is best for your particular needs? Call or live chat with one of our sales agents today and see the difference Hivelocity can make for you.