Troubleshooting CGI scripts

Learn how to troubleshoot CGI scripts with this helpful guide. Walk through five steps to determine the issue and implement a fix.

If you have a CGI (Common Gateway Interface) script that is not working, you can follow these troubleshooting steps:

Step #1: Verify script file permissions

Our shared web servers run CGI scripts under your user ID. If a CGI script does not run, one of the most common causes is that the execute permission is not set on the file. Make sure that the CGI script file has the correct permissions set.

📘

Note

For more information about file permissions for Perl script files, please see this article.

Step #2: Verify the shebang

Make sure the CGI script file uses the correct shebang. CGI script files must start with the correct shebang, or else the Apache web server will not know how to run the file. For more information about the shebang and how to use it, please see this article.

Step #3: Run the script from the command line

Trying to debug a CGI script through a web browser is often a frustrating process. For example, if you receive a "500 Internal Server Error", the root cause could be file permissions, a syntax error, or something else entirely. You can obtain much more useful information about script errors by logging in to your SSH account and running the script from the command line.

Step #4: Check web server error logs

The web server's error log may contain valuable information about why a CGI script is not running. Scripts that cause a "500 Internal Server Error" or "403 Forbidden" error message are logged in the web server's error log. You can use cPanel to view the error log for your web site.

Step #5: Open a ticket with our Support team

When your best attempts to fix a CGI script are unsuccessful, hope is not lost. If you need further assistance, please open a support ticket at https://my.hosting.com and we will assist you.