...

Solving a 500 Internal Server Error

Solving a 500 Internal Server Error

This tutorial will show you a number of methods for solving a 500 Internal Server Error

HTTP Error 500 – Internal server error

From the number of questions we get from new developers, it seems that one of the most dreaded errors that newcomers to PHP/Mysql and CGI face is the ambiguous “500 Internal Server Error”. It is one of the most uninformative error messages you can receive which can mean anything from an improper upload to a bug or error in the script and in most cases, incorrectly set file and directory permissions.

Information

Your Web server encountered an unexpected condition that prevented it from fulfilling the request by the client (e.g. your Web browser or our server robot) for access to the requested URL.

This is a ‘catch-all’ error generated by your Web server. Basically this means something has gone wrong, but the server can not be more specific in its response to the client.

500 errors in the HTTP cycle

Any client (e.g. your Web browser or our robot) goes through the following cycle when it communicates with your Web server:

  • Obtain an IP address from the IP name of your site (your site URL without the leading ‘http://’). This lookup (conversion of IP name to IP address) is provided by domain name servers (DNSs).
  • Open an IP socket connection to that IP address.
  • Write an HTTP data stream through that socket.
  • Receive an HTTP data stream back from your Web server in response. This data stream contains status codes whose values are determined by the HTTP protocol. Parse this data stream for status codes and other useful information.

This error occurs in the final step above when the client receives an HTTP status code that it recognises as ‘500?.

For the uninitiated, a “500 Internal Server Error” is a message much like the common “404 File Not Found” message. You get the latter message in your browser when you try to access a non-existent web page. You get the “500 Internal Server Error” message when you try to run a script with problems.

File Permissions

FASTDOT’s Apache servers are protected with SuExec and additional PHP hardening modules like, Suhosin and Mod_Security . As such any files which are running the insecure file permission of 777 will result in a 500 error.

No files or directories should be set with full read, write & execute permissions, commonly referred to as 777 permissions. This would pose a great security risk and will always result in a 500 server error!

For some background information on file permission settings and values and what it all means, you can visit our CHMOD/File Permissions tutorial!

HTTP 500 errors – Common Causes

Even though a 500 error is generally a ‘catch-all’ error message, the problem usually comes down to two very common mistakes:

  • A file or folder permissions issue when attempting to access a script. Again for the security of your website scripting files incorrectly setup with full 777 permissions will fail and generate this error. Generally permissions can be set at 755 but this will be dependant on the script you are trying to use. You will need to make sure you correctly set file and folder permissions for any scripts you use to ensure they run smoothly.
  • An error within a script file that has caused it to fail, or output an error message before it could finish its task and produce valid HTML. Can occur for a variety of reasons such as a script becoming corrupted, or having invalid code, even small syntax errors.

It can be tricky to track down 500 errors, but you should always start by checking that the correct file permissions are set and then further at the scripts themselves. The most obvious starting point will be the area of your site that generated the 500 error. For example, if you were using an online shopping cart script, and adding items to the cart on your site when a 500 error is generated, the first place to look might be the scripting files specific to that function. Checking the correct permissions, and further to that checking the script itself are all correct.

You can adjust file and folder permissions of your website in the following ways:-

  • Using your cPanel account and the “File Manager” – via the explorer styled menu, simply adjust the “Permissions” entry on the right of each listed file and folder.
  • Using your FTP account, and using your specific FTP clients Permissions or CHMOD controls to modify the file permissions.

Note: While most FTP clients will support this widely used command, certain FTP clients may not. FASTDOT reccomend using FileZilla, CuteFTP, WS_FTP and we offer a range of video tutorials for managing file permissions with these programs

A 500 Internal Server Error is a generic error message that indicates that there was a problem with the web server that is hosting the website. This error message does not provide much information about the specific issue, so it can be difficult to diagnose and resolve the problem. However, there are a few things that you can do to troubleshoot the issue:

  1. Check the server logs: Most web servers log errors and other important events. You can check the server logs to see if there are any error messages that provide more information about the problem. The server logs can usually be accessed through a control panel or FTP.
  2. Disable plugins or themes: If you are using a CMS like WordPress, a 500 error may be caused by a plugin or theme that is not working correctly. Try disabling all plugins and switching to a default theme to see if the problem goes away.
  3. Increase PHP memory limit: A 500 error may occur if the PHP memory limit is too low. You can try increasing the PHP memory limit by adding a line of code to the wp-config.php file (for WordPress sites) or the .htaccess file.
  4. Check file permissions: Make sure that the files and directories on your web server have the correct permissions. If a file or directory does not have the correct permissions, the web server may not be able to access it and may return a 500 error.
  5. Contact your web host: If none of the above steps resolve the issue, you may need to contact your web host for assistance. They may be able to provide more information about the problem or fix it on their end.
Previous Post
Top 10 Tips for SEO
Next Post
File Permissions Explained with CHMOD

Get Online Today!

  

Your perfect domain name is waiting!

Search our huge portfolio for more domain name extensions and pricing below
domain name extensions

Classic Domain Names

.COM | .AU | .CO | .NET | .BIZ | .ME | .EU | .ASIA | .TV | .MOBI | .NAME | .INFO | .ORG | .US | .NL| .FM | .HK | .ES | .CO.NZ | .DE | .CO.UK | .RU | .IM | .PM | .TW | .FR | .CN | .CA | .CH | .VN | .PL | .IL | .JP | .KR |