I have a django website deployed in digital ocean. I also considered adding a load balancer since i am expecting a heavy request in my backend. But i keep having an error of connection refused while connecting to upstream.
Here is the actual error:
2023/12/09 15:22:51 [error] 508980#508980: *2462 connect() failed (111: Connection refused) while connecting to upstream, client: 10.116.0.21, server: www.xxxxx.com, request: "POST /api/xxxxx/ask/ HTTP/1.1", upstream: "http://[::1]:8000/api/xxxxx/ask/", host: "xxxxx.com"
I tried to do something like this on my nginx:
upstream http_backend {
server 127.0.0.1:8000;
keepalive 16;
}
server {
listen 80;
server_name xxx.xxx.xxx.xxx;
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_pass http://http_backend;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location /static/ {
autoindex on;
alias /var/www/django-project/main/static/;
}
location /media/ {
autoindex on;
alias /var/www/django-project/main/media/;
}
}
why this happens?