The Django site opens after deploying, but pages are black text on white, /admin/ has no colours, and the browser’s developer tools (Network tab) show 404 for files such as /static/admin/css/base.css. The code is fine; nothing is serving those files.
Why it happens
In development (DEBUG=True), Django serves static files itself. In production it stops, and expects you to gather them into one folder with collectstatic so the web server can serve them. On cPanel hosting the app root sits outside public_html to protect the code, so if the files are collected inside the app folder, the web server never finds them.
Quick check: open a file URL directly, such as https://example.com/static/admin/css/base.css. A 404 means the files are in the wrong place or were never collected.
Causes and fixes, in order
1. collectstatic wasn’t run, or STATIC_ROOT isn’t set
What you see: no static folder in the domain’s root, or the command fails with You're using the staticfiles app without having set the STATIC_ROOT setting.
Fix: in settings.py:
STATIC_URL = "/static/"
STATIC_ROOT = "/home/USER/public_html/static"
Then over SSH inside the app’s environment (the command at the top of the app’s page in Setup Python App):
source /home/USER/virtualenv/myapp/3.12/bin/activate && cd /home/USER/myapp
python manage.py collectstatic --noinput
2. STATIC_ROOT is outside the right document root
What you see: the folder exists and has files, but the URL returns 404.
Fix: STATIC_ROOT must be inside the document root of the domain set as Application URL. For the main domain that’s usually public_html; for a subdomain it’s a folder such as /home/USER/api.example.com, which cPanel shows under Domains. Run collectstatic again after changing it.
3. You want a fix that doesn’t depend on folders: WhiteNoise
Fix: WhiteNoise lets Django serve static files efficiently in production. Install it in the virtualenv with pip install whitenoise, add it to requirements.txt, then in settings.py:
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
# the rest of your middleware
]
STATIC_ROOT = BASE_DIR / "staticfiles"
Run collectstatic, then Restart. If you then get a 500 with Missing staticfiles manifest entry, see Python app returns 500.
4. Templates hard-code paths
What you see: some files load and others don’t, or they only work on the home page.
Fix: use the {% static %} tag instead of relative paths:
{% load static %}
<link rel="stylesheet" href="{% static 'css/site.css' %}">
5. An old copy is cached
What you see: the file loads but your changes don’t show.
Fix: hard-refresh with Ctrl+F5 and purge the cache in Cloudflare if you use it. With ManifestStaticFilesStorage or WhiteNoise, every changed file gets a new name, so stale copies stop being a problem.
How to confirm it’s fixed
/static/admin/css/base.css opens and shows CSS, /admin/ has its colours, and the Network tab shows no 404s.
Prevention
- Make
collectstatic --noinputa fixed step after every deploy. - Test locally with
DEBUG=Falsebefore uploading. - For non-Django projects see CSS and JS not loading and images not showing.
On ArabyHost
On ArabyHost AI/Developer plans, Django runs through Setup Python App (Python 3.9 to 3.12 with Phusion Passenger) behind LiteSpeed, with SSH jailed in CageFS for collectstatic and migrate. The Django deploy guide shows where STATIC_ROOT goes for each kind of domain, and Django hosting explains what works and what doesn’t. Araby AI reads the error log and explains the fix.
FAQ
Why do files show with DEBUG=True and vanish with DEBUG=False?
Django serves static files automatically in development only. In production it expects the web server to serve them from `STATIC_ROOT` after `collectstatic`, or WhiteNoise to handle them.
Can I just leave DEBUG=True so the files show?
No. DEBUG=True in production shows your settings to any visitor when an error happens and uses more memory. Fix static files with one of the two methods and keep DEBUG=False.
Images that users upload don't show either. Same problem?
Nearly. Media files (`MEDIA_ROOT`) aren't copied by `collectstatic` and WhiteNoise doesn't serve them. Point `MEDIA_ROOT` at a folder inside the domain's root, such as `/home/USER/public_html/media`, with `MEDIA_URL = "/media/"`.