Click here to Skip to main content
15,901,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to deploy a Django Channel Application with Daphne and nginx. I am getting 502 Bad Gateway error when I try to access the application from a web browser.

I am using AWS EC2 Ubuntu instance to host the web application. Following is my nginx config file.

Python
upstream channels-backend {server localhost:8000;}
        
    server {
    listen 80;
    server_name 52.77.249.57;
    location = /favicon.ico { access_log off; log_not_found off; }
         
    location / {
    proxy_pass http://channels-backend;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    }
  }

Following is my daphne.service file.
Python
[Unit]
Description=daphne daemon
Requires=daphne.socket
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/home/ubuntu/project
ExecStart=/home/ubuntu/project/env/bin/daphne -b 0.0.0.0 -p 8000 
chat_service.asgi:application

[Install]
WantedBy=multi-user.target

Do you have any idea to solve the issue ?

What I have tried:

I tried with above config files and still no results.
Posted
Updated 6-May-24 5:54am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900