Hébergements Starter, Perso, Pro ou performance - in Webhosting most Python scripts end with HTTP 500
... / in Webhosting most Python...
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Frage

in Webhosting most Python scripts end with HTTP 500

Von
Tony Wid
Erstellungsdatum 2026-04-06 14:39:30 in Hébergements Starter, Perso, Pro ou performance

In Webhosting (called from Webbrowser) *most* Python scripts end with HTTP 500,

example www.mysite.com/python/mypycript.cgi
or www.mysite.com/anyfolder/mypage.html (html contains iframe to mypyscript.cgi)

However: These scripts can be successfully executed via commandline (via Putty),
example python mypyscript.cgi.

All are in the same folder.

scripts properties:

extension = .cgi
access-right = executable (744 or 705)

Example which cannot be executed:

#!/usr/bin/python

print ("hallo wd")

What can be the reason?


1 Antwort ( Latest reply on 2026-04-07 21:05:18 Von
Tony Wid
)

Hello,

Have a look in your customer portal > hosting > logs > web error log

You will probably find a more comprehensive error message. Maybe Python is not supported in the environment that runs the web server (the ssh environment is different). Or the path to the python3 executable is incorrect.

 

thank you!

I found "06.04.26 20:05:04 | INFO | End of script output before headers: test3.py.cgi " which was not helpful.

Now I had two identical files, and one runs successfully the other brought an error when running via cgi.
Both however can run via commandline (in putty).
The difference is the kind of linebreaks:
o) unix x'0A' => successful
o) windows x'0D0A' => error

Is there a possibility to handle this problem? Maybe some config in webhosting (to accept windows linebreaks), filetransfer (to modify linesbreaks) or pycharm (to write unix linesbreaks).

and additional: the "print" output must start with

o)  a header line plus empty line
o) or at least an empty line

# print("Content-type: text/html") .. optional
print("") # WICHTIG: Leerzeile!

Btw. is it possible to execute .py files (instead of needing to rename it to .cgi)?

[originally there was already a reply but it disappeared]

meanwhile I know the reason: 

py-files had different linebreaks,
unix X'0A' - run successfully
windows X'0D0A' brought an error when called from browser, and successful via commandline (putty)