---
title: "How to Deploy a Django App | Hostman Docs"
description: "Follow this guide to deploying your Django app on Hostman. Learn how to set up, configure, and optimize your app for smooth deployment."
---

> For the complete documentation index for AI agents, see [llms.txt](https://hostman.com/llms.txt).

You can find the step-by-step deployment guide [here](https://hostman.com/docs/app-platform/backend-apps/).

## Application Build

Hostman uses the following environment when building a Django application:

-   Python 3.10, 3.11, 3.12, 3.13, or 3.14
-   pip
-   gunicorn
-   System libraries for working with PostgreSQL and MySQL

Hostman will execute the following commands during the build:

```shell
apt-get install -y python3 python3-pip gunicorn python3-psycopg2 libpq-dev python-dev default-mysql-client python3-dev default-libmysqlclient-dev python3-mysqldb --fix-missing
pip3 install psycopg2 django
ln /usr/bin/python3 /usr/bin/python -sf
ln /usr/bin/pip3 /usr/bin/pip -sf
```

To install dependencies, add the following line to the build command:

```shell
pip3 install --upgrade -r requirements.txt
```

The default start command is:

```shell
python3 manage.py runserver 0.0.0.0:8000
```

You can also define environment variables. For example, to specify the hosts from which Django is allowed to receive requests, set the `DJANGO_ALLOWED_HOSTS` key with a value containing IP addresses or hostnames. You can specify multiple hosts, separated by commas without spaces. By default, this variable is set to `127.0.0.1,localhost`.

For more details on configuration, refer to the [Django documentation](https://docs.djangoproject.com/en/5.2/ref/settings/).

## Requirements

-   Make sure that the `manage.py` file is located in the root of the project and is used as the application's entry point.
-   Make sure to set `DEBUG=True` in the settings; otherwise, static files will not be served.
-   Make sure the application is listening on `0.0.0.0` rather than `127.0.0.1`; otherwise, external connections will not work.

## Troubleshooting

### Deployment fails

If there are problems with deployment, first check the deployment log. You will be able to determine at what point something went wrong.

Often the problems are related to the start command. Check that everything in your development environment works with `gunicorn`. Make sure that all modules required to run the application are present in the `requirements.txt` file.

### DisallowedHost at /Invalid HTTP\_HOST

The problem occurs when the hostname is not specified in the `settings.py` file.

This setting is a security measure to prevent HTTP Host header attacks.

To fix the problem, you need to make changes to the `settings.py` file, specifying your domain in the `ALLOWED_HOSTS` directive, for example:

```shell
ALLOWED_HOSTS = ["your.domain.com"]
```

You can also allow all domains if you don't want to use this security measure:

```shell
ALLOWED_HOSTS = ["*"]
```
