How to host Django on Square Cloud (step by step)
Looking for where to host a Django app or the best way to put a Django app online? This guide shows the step-by-step to host Django on Square Cloud — from settings.py (ALLOWED_HOSTS) to deploying with Gunicorn, running 24/7.
1. Prerequisites
- Square Cloud Account: Create your account via the Registration Page (email, Discord, GitHub or Google).
- Active Plan: A paid plan is required for hosting. Check the pricing here.
2. Production Settings (settings.py)
Before deploying, you need to adjust your Django project's settings.py file to allow Square Cloud traffic:
- ALLOWED_HOSTS: Add the subdomain you intend to use and the Square Cloud domain.
ALLOWED_HOSTS = ['yoursubdomain.squareweb.app', 'yourdomain.com', 'localhost', '127.0.0.1']
CSRF_TRUSTED_ORIGINS = ['https://yoursubdomain.squareweb.app', 'https://yourdomain.com']
- CSRF_TRUSTED_ORIGINS: Behind Square Cloud's HTTPS, forms (including the admin) return 403 CSRF without it.
- DEBUG: For production, remember to set
DEBUG = False. - Static Files: Make sure to configure
STATIC_ROOTso Django knows where to collect static files.
3. Performing the Deployment
- Cleanup: Remove unnecessary folders such as
venv/,.git/, and__pycache__cache files. - Compression: Create a
.zipfile containing the root of the project (where themanage.pyfile is located). Therequirements.txtfile must be in the project root and contain at least:
Django
gunicorn
whitenoise
- Upload: In the Square Cloud Dashboard, click on upload new application.
- Web Publication: In the upload form, open the advanced settings and fill in "Web Publication" (Subdomain). It must be set on the first upload.
- Subdomain: Define the desired subdomain (e.g.,
myproject.squareweb.app). - Custom Start Command: For your Django application to run in production, you must configure the start command to use Gunicorn on port 80. At the time of upload or in the
squarecloud.appfile, use:
python -m gunicorn --bind 0.0.0.0:80 your_project.wsgi:application--bind 0.0.0.0:80: Binds the application to the interface and port required by Square Cloud.your_project.wsgi:application: Replaceyour_projectwith the name of the folder containing thewsgi.pyfile.
4. Custom Domains (Standard+ Plan)
If you have a Standard plan or higher, you can use your own domain:
- Configure the domain (e.g.,
www.yoursite.com) in the Network tab. - SSL (HTTPS) is automatically configured and renewed by Square Cloud at no additional cost.
5. Optimization and Security Tips
- Static Files: Gunicorn doesn't serve static files. Install WhiteNoise (its middleware right after
SecurityMiddleware) and run collectstatic, for example in the start command:python manage.py collectstatic --noinput && python -m gunicorn your_project.wsgi --bind 0.0.0.0:80. - Environment Variables: Use the Dashboard's ENV tab to hide your
SECRET_KEYand database credentials. Never leave passwords exposed in the code sent to the repository or dashboard. - Database: For production, use PostgreSQL or MySQL instances available on Square Cloud, avoiding the use of SQLite in applications that require scalability.
Updated on: 10/04/2026
Thank you!
