Jump to content

Yet Another 500 Internal Server Error (Reposted In Correct Forum)


Recommended Posts

Posted (edited)

Hello, world! Let me first of all say that I greatly appreciate the existence of Heliohost, a free, honest hosting provider with support for pure python 3.4. Just what I was looking for.

 

Username: eliashas

Domain: eliashasle.heliohost.org

Server: Stevie

 

I have created a web application in Python, which runs smoothly on my localhost, but does not load at all on heliohost. I have even reduced the complexity to a simple Hello world: http://eliashasle.heliohost.org/cgi-bin/helloworld.py:

#!/usr/bin/python

print("Content-Type: text/html;charset=utf-8\n\n")
print("<html><body><p>Hello, world!</p></body></html>")

 

test.pl does not work either:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print <<HTML;
<html> <head> <title>A Simple Perl CGI</title> </head> <body> <h1>A Simple Perl CGI</h1> <p>Hello World</p> </body>
HTML
exit;

 

500 Internal server error, it seems. No more info found in the error log.

 

500 errors can be caused by a lot of things. The most common are

Exceeding Process Limit The solution is to not run as many processes. Opening cpanel' date=' connecting to FTP, checking mail, connecting to webdisk, etc all increase your process count, and if you exceed your limit php will show 500 errors since it cannot start a new php process. This sometimes affects only the webmaster since opening cPanel and FTP etc is common when you're editing your site, but normal users won't have these errors since they will only be accessing your website not all the other services. The process limit is higher on Johnny so for some websites the solution to 500 errors might be to switch servers.

Syntax Error in .htaccess If you have a syntax Error in one of your .htaccess files it can cause a 500 error. The easiest way to check if this is the case is to delete or rename your .htaccess files and see if the 500 Error goes away.

Incorrect Permissions If the script or the directory that the script is in doesn't have the correct permissions it can cause 500 errors too. If you're running a php script the file permission should be 644. If you're running a cgi script it should have 755 permissions. Your directories should have 755 or 750 permissions.

Exceeding Time Limit If your script exceeds the time limit it can be killed by the system which will also result in a 500 error. The solution to this problem is to break your long executing scripts into multiple faster scripts that can call each other. For instance longscript.php always results in a 500 Error because it exceeds the time limit, but if script1.php runs for a short time, and then calls script2.php which calls script3.php they can together execute the same code as longscript.php without exceeding the time limit and being killed.

High Server Load If the Server is currently experiencing high Server load scripts can return a 500 Error when they would normally work. This is more common on Johnny than Stevie since Johnny is more unstable, and accounts that cause high load on Stevie are suspended. There isn't really anything that can be done about high load 500 errors other than trying again later when the load is lower.[/quote']

 

1. I have tried closing all other connections, like cpanel and ftp.

2. No custom .htaccess file.

3. Permissions set to 755 for cgi-bin and the scripts within. I did this via SFTP on FileZilla, and confirmed it with the file manager in cpanel.

4. Hello world shouldn't exceed any time limit.

5. Not likely, as it is every single time, regardless of when I try.

 

I am beginning to believe that this must be an error in the service, but I don't know. I would greatly appreciate any help.

Edited by eliashas
Posted

I solved it! The scripts were made in Windows, so i ran the linux program dos2unix on them. now helloworld.py works. don't know why. Maybe this is a common problem?

Posted

Our servers are Linux. Python likely didn't like the line endings and died processing it, causing apache to kick out a 500 when python didn't return valid data. Of course, it'd work just fine on windows...

 

Python I've found to be very picky about details that don't matter to most others. Its pickiness is why I use php for web development.

Posted

Php uses brackets around block statements, in fact, the entire block can be one line if you prefer, since every line ends with a semicolon. <?php if (1==1) { echo "This is always run"; echo "and this is too!"; } ?> Is a perfectly valid block if statement.

 

Php can care less about line endings, line breaks, white space, or anything else as long as the syntax is correct.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...