Django channels - connection timed out

Posted October 31, 2020 2.3k views

I created a django-channels app that works without any problem in local. I’m now trying to deploy it to a DigitalOcean droplet. The whole Django WSGI part works, the only part not working is Django-Channels. If i try to connect to any consumer like below:


I get the following error on my Chrome console:

WebSocket connection to 'ws://MYURL:9000/main' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

Daphne service:

Description=Daphne service

ExecStart=/django-vue-mpa/venv/bin/daphne --bind --port 9000 --verbosity 0 django_vue_mpa.asgi:application
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID


And here is my actual nginx conf:

server {
    listen 80;
    server_name http://MYURL/;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /django-vue-mpa/django_vue_mpa;

    location / {
        include proxy_params;
        proxy_pass http://unix:/django-vue-mpa/django-vue-mpa.sock;

What am i doing wront here? The exact same code works locally, but it looks like whenever i try to access django channels from outside i get refused.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi @hst02,

This usually is something simple. I’ll recommend checking if the port you are using 9000 is actually allowed to the public.

The error you’ve provided often indicates exactly that.