My CGI/Perl scripts are failing with error 500 (Internal Server Error)

These errors are nearly always related to a coding error within the script, or bad variables being passed into the script. If you encounter an error "500 Internal Server Error" whilst running your CGI and Perl scripts, try the following in order:

- Ensure you have uploaded the script through FTP using ASCII mode (not Binary), or that it has Unix-style carriage returns.

- Check the interpreter path on the first line of the script. For Perl it should
always be "#!/usr/bin/perl".

- Make sure the script filename ends in either ".pl" or ".cgi".

- Make sure the script can execute. It should have permissions of "755". Most FTP clients support this.

- Put "use CGI::Carp qw(fatalsToBrowser);" into the second line of your
script. This will make Perl print the error instead of the "500 Internal Server Error" page, and will allow you to find out where your script is breaking.

Other potential problems include bad syntax in an .htaccess file (if you've created/edited one). Check your error log for details (there are articles on how to get to your error logs).

  • 56 Users Found This Useful
Was this answer helpful?

Related Articles

My CGI/ASP/PHP script is giving an error when trying to write to a file.

This applies to Linux hosting accounts only.This is almost certainly down to incorrect...

I've installed the formmail script, but my form isn't working. Why?

The Formmail Script is provided via the Fast Name Control Panel, full usage instructions can be...

Why does my script produce a 'file permissions error'?

CGI scripts need certain file permissions to be set if they are to work properly. In general CGI...

CGI scripts fail with 'exec format error'

A CGI script must begin with a valid 'interpreter line' also called 'shebang'. That must be the...

Accesses to all files result in '500 Internal Server Error' messages

500 Internal Server Error messages on every page are typically an indication of a misconfigured...