Daphne server shuts down after startup

I have a Django Rest Framework application with Daphne, I have ASGI server configured.
When starting the server everything seems fine, but after a few seconds it stops, without providing the reason why it is stopping.
What could be the problem?


2023-09-25 20:34:29,645 INFO     Starting server at tcp:port=8000:interface=
2023-09-25 20:34:29,646 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2023-09-25 20:34:29,646 INFO     Configuring endpoint tcp:port=8000:interface=
2023-09-25 20:34:29,647 INFO     Listening on TCP address
2023-09-25 20:35:33,731 INFO     Killed 0 pending application instances


import os
from channels.routing import ProtocolTypeRouter
from django.core.asgi import get_asgi_application

default_asgi_application = get_asgi_application()

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'simple_chat.settings')

application = ProtocolTypeRouter({
  "http": default_asgi_application,


from os import environ
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent
DEBUG = True





AUTH_USER_MODEL = 'chat.CustomUser'

ROOT_URLCONF = 'simple_chat.urls'

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [

WSGI_APPLICATION = 'simple_chat.wsgi.application'

    'default': {
        'ENGINE': environ.get('ENGINE'),
        'NAME': environ.get('NAME'),
        'USER': environ.get('USER'),
        'PASSWORD': environ.get('PASSWORD'),
        'HOST': environ.get('HOST'),
        'PORT': environ.get('POSTGRESQL_PORT'),

        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',

USE_I18N = True
USE_TZ = True

STATIC_URL = 'static/'
ASGI_APPLICATION = 'simple_chat.asgi.application'

    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'CONFIG': {
            'hosts': [environ.get('REDIS_URL')]

  'http://localhost:3000' if environ.get('IN_DEVELOPMENT') else 'https://globalpage.com'

Hello, which kind of instances your service is running on? If it is a nano instance, did you try running your service from a bigger instance?

I suspect 256MB of ram is not enough to host your Python application, and that’s why your process is getting killed.

Yes, I was using the nano instance, but it seems to me that it is not a question of the instance, I already tried the Micro and Small instance and the same thing still happens.
Also, I previously deployed my application but with the WSGI server and with the Nano instance it worked without a problem, but now that I try to deploy as an ASGI server it gives me that error.

Maybe I should configure my project as if I were deploying it to Heroku?

I found the solution, which is to configure the project as if you were deploying it to Heroku.

Add 2 files, the Procfile and runtime.txt file

Procfile content:

release: python manage.py migrate
web:daphne simple_chat.asgi:application --port $PORT --bind -v2
worker: python manage.py runworker channels --settings=simple_chat.settings -v2

runtime.txt content:
version of python you used

1 Like