Django asgi deployment failing

I currently have a Django ASGI project that runs well locally, but when I try to deploy it on Render I encounter an error.

Below are my build script (, Procfile, and relevant sections:


import django
import os
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from import AllowedHostsOriginValidator
from django.core.asgi import get_asgi_application


from chat.routing import websocket_urlpatterns

from hometweet.routing import websocket_urlpatterns
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "root.settings")

django_asgi_app = get_asgi_application()

application = ProtocolTypeRouter(
"http": django_asgi_app,
"websocket": AllowedHostsOriginValidator(

Build Script (


# Upgrade pip and setuptools
pip install --upgrade pip
pip install --upgrade setuptools

# Install Dependencies
pip install -r requirements.txt

# Run Migrations
python makemigrations user
python makemigrations hometweet
python makemigrations profiles
python makemigrations groupapp
python migrate

gunicorn root.asgi:application -k uvicorn.workers.UvicornWorker. 

Please someone should help me out on how i can deploy it either on render thanks

I've tried various start commands, including:

- web: daphne -u /tmp/daphne.sock yourproject.asgi:application
- web: gunicorn root.wsgi:application
- gunicorn root.wsgi:application
- web: gunicorn root.asgi:application
- gunicorn root.asgi:application
- web: gunicorn root.asgi:application -k uvicorn.workers.UvicornWorker

The last command is currently giving me a server error when attempting to access the page. is there something i need to change or add please.

Hi there,

It’s hard to know exactly what your start command should be without knowing the directory structure of your application.

Assuming your is a directory called root then gunicorn root.Asgi:application should be okay (note the capital A because your py file starts with this). gunicorn root.Asgi:application -k uvicorn.workers.UvicornWorker should also be okay if you want to use Uvicorn workers with your service.


Render Support, UTC+10 :australia:

my is in my project root directory called root. i tried gunicorn root.Asgi:application and i got no module named root.Asgi

Hi there,

It looks like your has a lowercase a, so gunicorn root.asgi:application -k uvicorn.workers.UvicornWorker would work.

You also need to rename the environment variables you use to connect to your database. Add something like DB_ to the front on them. Using PORT as one of them is causing us problems detecting the port your service uses. I’d actually recommend just using the internal URL and making the environment variable DATABASE_URL, see our example here of how you can use this:


Render Support, UTC+10 :australia:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.