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:
ws://MYURL:9000/main
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:
[Unit]
Description=Daphne service
After=network.target
[Service]
PIDFile=/run/daphne/pid
User=root
Group=root
WorkingDirectory=/django-vue-mpa
ExecStart=/django-vue-mpa/venv/bin/daphne --bind 0.0.0.0 --port 9000 --verbosity 0 django_vue_mpa.asgi:application
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
Restart=on-abort
PrivateTmp=true
[Install]
WantedBy=multi-user.target
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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.