Deploy django-channels to

I implemented django-channels and daphne, and it works locally based on this tutorial :
Tutorial — Channels 3.0.3 documentation

However, I have difficulties to deploy the application to render based on these guidelines
Deploying — Channels 3.0.3 documentation

I have set the following start command

daphne my_app_name.asgi:application

Here is

import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_app_name.settings")
from channels.http import AsgiHandler
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
import chat.routing
application = ProtocolTypeRouter({
    "http": AsgiHandler(),
     "websocket": AuthMiddlewareStack(

And here is the error returned when I try to deploy :

Mar 12 10:50:39 AM  2021-03-12 10:50:39,398 INFO     Starting server at tcp:port=8000:interface=
Mar 12 10:50:39 AM  2021-03-12 10:50:39,399 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
Mar 12 10:50:39 AM  2021-03-12 10:50:39,399 INFO     Configuring endpoint tcp:port=8000:interface=
Mar 12 10:50:39 AM  2021-03-12 10:50:39,400 INFO     Listening on TCP address

But the deployment cannot be finalized (it runs indefinetely).

Any idea what I am doing wrong? Is there a problem with the IPs ? Django-channels guidelines indicate we can also specify the port and IP that Daphne binds to. e.g. :

daphne -b -p 8001 myproject.asgi:application

Thanks a lot

Hey @jpuaux, I think you may have answered your own question! Render services should bind to (all available network interfaces) rather than (localhost). Let us know if you continue to see issues after making that change.

It is working with the following command :

daphne -b pcaexpress.asgi:application

Thanks a lot for your answer.

1 Like