Contents
You uploaded a Django or Flask project, created the app in cPanel, and the site opens on 500 Internal Server Error or “We’re sorry, but something went wrong”. Passenger started Python, but the code raised an exception. The page hides it, so start with the log.
First: see the real error
- In Setup Python App, open the app and check the log file path, or set it to
/home/USER/logs/myapp.log, click Restart, load the site once, and read the last traceback in the file. - Over SSH, copy the command shown at the top of the app’s page to enter its environment, then import the entry file yourself:
source /home/USER/virtualenv/myapp/3.12/bin/activate && cd /home/USER/myapp
python -c "import passenger_wsgi"
If it prints nothing, the app loads fine and the error happens while handling a request.
The most likely causes, in order
1. A package isn’t installed in the virtual environment
What you see: ModuleNotFoundError: No module named 'django' or another package. Installing with pip outside the app’s virtual environment doesn’t help the app.
Fix: on the app’s page, add requirements.txt under Configuration files and click Run Pip Install, or run pip install -r requirements.txt after the source command above. More in ModuleNotFoundError.
2. passenger_wsgi.py doesn’t expose the right app
What you see: an AttributeError about application, or “It works!” instead of your site.
Fix: Passenger calls an object named application. Make the file look like this for your framework:
import os, sys
sys.path.insert(0, os.path.dirname(__file__))
# Django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from mysite.wsgi import application
# Flask (instead of the two lines above)
# from app import app as application
Replace mysite with the folder that contains settings.py.
3. Missing environment variables or settings
What you see: KeyError: 'SECRET_KEY' or ImproperlyConfigured.
Fix: add the variables under Environment variables on the app’s page; a .env file is only read if your code loads it. In Django with DEBUG=False, send errors to the log by adding this to settings.py:
LOGGING = {
"version": 1,
"handlers": {"console": {"class": "logging.StreamHandler"}},
"loggers": {"django": {"handlers": ["console"], "level": "ERROR"}},
}
4. Database tables missing or a wrong connection
What you see: no such table, Table ... doesn't exist, or OperationalError.
Fix: create the database in MySQL Databases, use the full prefixed database and user names with HOST set to localhost, then run python manage.py migrate. If you use SQLite and get a write error, see SQLite is read-only.
5. A static file missing from the manifest
What you see: ValueError: Missing staticfiles manifest entry. It happens with ManifestStaticFilesStorage or WhiteNoise when collectstatic wasn’t run.
Fix: run python manage.py collectstatic --noinput, then Restart, and see Django static files not loading.
How to confirm it’s fixed
python -c "import passenger_wsgi" runs without errors, no new traceback appears in the log after loading a page, and both the main pages and /admin/ open.
Prevention
- Test locally with
DEBUG=Falsebefore uploading. - Keep packages in
requirements.txtwithpip freeze > requirements.txt. - Make
migrate,collectstaticand a restart fixed steps of every deploy.
On ArabyHost
On ArabyHost AI/Developer plans, Python 3.9 to 3.12 apps run through Setup Python App (the CloudLinux selector with Phusion Passenger), with SSH jailed in CageFS. Araby AI reads the error log and explains what caused the 500. For the full setup see the Django, Flask or FastAPI guide, or AI/Developer hosting.
FAQ
I see It works! instead of my site. Why?
That's the default `passenger_wsgi.py` that Setup Python App creates. Replace its contents with a line that imports your app, such as `from mysite.wsgi import application`, then click Restart.
Should I set DEBUG=True to see the error?
Only for a few minutes if you must, because the debug page shows settings and paths to any visitor. Sending Django errors to the log, as shown below, is better, and DEBUG stays False.
What's the difference between a 500 and a 400 Bad Request in Django?
With DEBUG=False, Django answers 400 when the domain isn't in ALLOWED_HOSTS, while a 500 means an exception in code or settings. Add the domain and its www version to ALLOWED_HOSTS to fix the first.
Does FastAPI work the same way?
FastAPI needs an adapter because Passenger runs Python over WSGI. Wrap it with `a2wsgi` in `passenger_wsgi.py`; otherwise you get a 500 with a `TypeError` in the log.