If you're getting an “Internal Server Error†(500) while running a CGI script on 4GoodHosting, here’s how to troubleshoot and fix it specifically for their hosting environment:
Â
ðŸ› ï¸ Likely Causes & Solutions (Tailored for 4GoodHosting)
1. ✅ File Permissions
Your CGI script must be executable.
Fix:
-
Log into cPanel or use FTP.
-
Navigate to your
cgi-bin
directory. -
Right-click the script → Set permissions to 755
(Read & execute for everyone, write for owner)
Â
2. ✅ Correct Shebang Line (First Line of Script)
Your script must start with the correct interpreter path.
For Python:
For Perl:
Check with 4GoodHosting support or SSH (which python3
) to confirm the path. It must be absolute — #!/usr/bin/env python3
might not work.
Â
3. ✅ Content-Type Header is Required
CGI scripts must return proper HTTP headers before output.
Example (Python):
Missing this? You’ll get a 500 error immediately.
Â
4. ✅ Location of Script
CGI scripts must be placed in the cgi-bin/
directory (or an allowed folder).
Check:
-
Script is in
/public_html/cgi-bin/
or a folder allowed via.htaccess
.
Â
5. ✅ Fix Windows Line Endings
If you wrote the script on Windows, it may have incorrect line endings (\r\n
).
Fix:
-
Convert using a tool like
dos2unix
, or re-save the file using Unix (LF) line endings in your code editor.
Â
6. ✅ Check for Syntax Errors
Errors in your code will break execution.
Debug:
-
Add simple
print()
lines and narrow down the cause. -
Use try/except in Python to log any crash:
7. ✅ Check Server Error Logs (4GoodHosting)
In cPanel:
-
Go to Metrics > Errors OR File Manager > error_log
-
Look for the most recent error related to your script (often points to permission, shebang, or syntax problems)
Â
8. ✅ .htaccess Configuration (if outside cgi-bin/
)
If you're running CGI outside cgi-bin/
, you must enable CGI with .htaccess
:
Place this .htaccess
in the same directory as your script.
Â
✅ Final Checklist (4GoodHosting CGI)
Issue | Fix |
---|---|
File permissions wrong | chmod 755 or set 755 in cPanel |
Shebang path incorrect | Use #!/usr/bin/python3 or /usr/bin/perl |
Missing Content-Type | Add print("Content-Type: text/html\n") |
Not in allowed directory | Use /cgi-bin/ or allow via .htaccess |
Wrong line endings | Convert to Unix (LF) using dos2unix |
Script error | Check error_log in cPanel |
While we can't possibly troubleshoot scripts for everyone, if you are having serious problems and have read the instructions for your program, AND tried the above, then please open a trouble ticket and we will help you as best we can. We don't normally do script installation, but we don't like to leave our customers out in the cold eiter.