
In this tutorial, we will show you how to set up a Django Application with Gunicorn and Nginx on Debian 13 OS. A Django application is a Python web application built using the Django framework. It contains the business logic and database interactions and handles user requests. Gunicorn is a WSGI application server that runs the Django application and processes incoming requests. Nginx is a high-performance web server and reverse proxy that sits in front of Gunicorn. It serves static files efficiently, handles client connections, and forwards dynamic requests to Gunicorn, which then communicates with the Django application to generate responses.
To complete this setup, we will need around 15 minutes, as it is pretty straightforward. Let’s get started!
- A server running Debian 13 OS
- User privileges: root or non-root user with sudo privileges
- A valid domain name with a pointed A record to the server IP address
Table of Contents
Step 1. Update the system
Before we start installing Django, we need to update the system packages to their latest available versions. To do that, execute the following commands:
apt update -y && apt upgrade -y
Step 2. Python and its dependencies
Since Django is written in Python, we need to install it with its dependencies:
apt install python3 python3-venv python3-dev libpq-dev curl
Once done, verify the Python3 version with the following command:
python3 -V
You should get the following output:
root@host:~# python3 -V
Python 3.13.5
Step 3. Create a Python Virtual Environment
A Django project uses a Python virtual environment to isolate its dependencies and Python version, ensuring consistent development, avoiding package conflicts with other projects, and making deployment more reliable.
First, we will create a directory for our Django project:
mkdir -p /opt/myproject/
cd /opt/myproject
To create a virtual environment named “django-venv,” execute the following command:
python3 -m venv django-venv
Once created, activate the virtual environment with the command below:
source django-venv/bin/activate
The command prompt will change and will look like this:
(django-venv) root@host:/opt/myproject#
Step 4. Install Django
Now, when we are in an isolated virtual environment, we are ready to install Django with the following commands:
pip3 install --upgrade pip
pip3 install django
Once Django is installed, we need to initialize a new project in the current directory of our Django project:
django-admin startproject djangoproject .
Once the project is created, we need to apply the migrations:
python3 manage.py migrate
If everything is OK, you should receive the following output:
(django-venv) root@host:/opt/myproject# python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
Next, open the “settings.py” file and add your server IP address in the “Allowed Hosts” section so we can access the Django application via the IP address and port.
cd /opt/myproject/djangoproject/
nano settings.py
Add your IP address so it looks like this:
ALLOWED_HOSTS = ['192.168.1.3',] # Replace 192.168.1.3 with your server IP address
Save the file and close it.
Now we need to start the Django project so we can access it publicly via IP address and port:
python3 manage.py runserver 0.0.0.0:8000
Once started, the output should look like this:
(django-venv) root@host:/opt/myproject# python3 manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
July 12, 2026 - 17:30:51
Django version 6.0.7, using settings 'djangoproject.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or ASGI server instead.
For more information on production servers see: https://docs.djangoproject.com/en/6.0/howto/deployment/
As you can see above, Django is started in development mode and is accessible at http://YourServerIPAddress:8000.
/Image1
Press CTRL + C to stop the development process.
^C(django-venv) root@host:/opt/myproject#
The purpose of this tutorial is to make Django accessible in production via a domain name. To do that, we will install Gunicorn and later configure the Nginx proxy.
Step 5. Install Gunicorn
The Gunicorn installation is in the same directory as the virtual environment. To install Gunicorn, execute the following command:
pip install gunicorn
cd /opt/myproject/
gunicorn --bind 0.0.0.0:8000 djangoproject.wsgi:application
If we access the application in the browser, it will be accessible again. But if we close the terminal, the Gunicorn process will stop, so we need to create a service for it. To do that, create the following file:
nano /etc/systemd/system/gunicorn.service
Paste the following lines of code:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=root
Group=root
Restart=on-failure
WorkingDirectory=/opt/myproject/
ExecStart=/opt/myproject/django-venv/bin/gunicorn --bind 0.0.0.0:8000 djangoproject.wsgi:application
[Install]
WantedBy=multi-user.target
Save the file and close it.
Start and enable the Gunicorn service:
systemctl start gunicorn && systemctl enable gunicorn
To check the status of the service, execute the command below:
systemctl status gunicorn
You should get the following output:
root@host:/opt/django-project# systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; preset: enabled)
Active: active (running) since Sun 2026-07-12 13:03:43 CDT; 3s ago
Invocation: 06c9074900c94258a2751ef76785b8d5
Main PID: 14997 (gunicorn)
Tasks: 3 (limit: 4655)
Memory: 43.5M (peak: 43.5M)
CPU: 771ms
CGroup: /system.slice/gunicorn.service
├─14997 /opt/myproject/django-venv/bin/python3 /opt/myproject/django-venv/bin/gunicorn --bind 0.0.0.0:8000 djangoproject.wsgi:application
└─14998 /opt/myproject/django-venv/bin/python3 /opt/myproject/django-venv/bin/gunicorn --bind 0.0.0.0:8000 djangoproject.wsgi:application
Jul 12 13:03:43 host.test.vps systemd[1]: Started gunicorn.service - gunicorn daemon.
Jul 12 13:03:44 host.test.vps gunicorn[14997]: [2026-07-12 13:03:44 -0500] [14997] [INFO] Starting gunicorn 26.0.0
Jul 12 13:03:44 host.test.vps gunicorn[14997]: [2026-07-12 13:03:44 -0500] [14997] [INFO] Listening at: http://0.0.0.0:8000 (14997)
Now that the service is up and running, we can access the Django application at http://YourServerIPAddress:8000.
The last thing is to be accessible via a domain name, and that will be set up in the Nginx configuration. Let’s move to the last step.
Step 6. Install Nginx and Create a Reverse Proxy
To install Nginx, execute the following command:
apt install nginx -y
Once installed, start and enable the service:
systemctl start nginx && systemctl enable nginx
To check the status of the service, execute the following command:
systemctl status nginx
You should get the following output:
root@host:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
Active: active (running) since Sun 2026-07-12 18:03:06 CDT; 3min 3s ago
Invocation: cafdbf3fedf44add85d35516bb16a9ce
Docs: man:nginx(8)
Process: 16035 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 16036 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 16067 (nginx)
Tasks: 4 (limit: 4655)
Memory: 3.7M (peak: 9.1M)
CPU: 105ms
CGroup: /system.slice/nginx.service
Once Nginx is installed, create the Nginx configuration file for the reverse proxy configuration:
nano /etc/nginx/conf.d/django.conf
Paste the following lines of code:
server {
listen 80;
server_name YourDomainNameHere;
location / {
proxy_pass http://0.0.0.0:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Save the file and close it. Check the syntax of the newly added Nginx configuration file:
nginx -t
If everything is OK, you should receive the following output:
root@host:/opt/django-project# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart the Nginx service:
systemctl restart nginx
Add your domain name in settings.py so it looks like this:
ALLOWED_HOSTS = ['192.168.1.3','YourDomainNameHere.com']
That’s it; you can access your Django application with Gunicorn and Nginx at http://YourDomainNameHere.com.

Of course, you do not have to install it yourself if you have difficulty and are not familiar with Linux. All you have to do is sign up for one of our Django hosting plans and submit a support ticket. Our admins are available 24/7 and will help you with any aspect of installing Django.
If you liked this post on how to set up a Django Application with Gunicorn and Nginx on Debian 13, please share it with your friends on social networks or leave a comment below.
