Nginx refuses to connect to Django container in Lightsail

0

I have 2 images that I am uploading to aws lightsail.

If I upload the django one it works without any issue, but trying to add to it Nginx has not been possible as Nginx cannot connect to django.

I get this error:

[30/may/2023:16:13:38] 2023/05/30 16:13:38 [error] 30#30: *71 connect() failed (111: Connection refused) while connecting to upstream, client: 172.26.45.36, server: localhost, request: "GET / HTTP/1.1", upstream: "http://172.26.18.131:8000/", host: "172.26.2.175"
[30/may/2023:16:13:38] 172.26.45.36 - - [30/May/2023:16:13:38 +0000] "GET / HTTP/1.1" 502 157 "-" "ELB-HealthChecker/2.0" "-"

this is my nginx.conf file:

server {
    listen 80;
    server_name localhost;

    location /static/ {
        root /jp/static;
    }

    location / {
        proxy_pass http://myservice.service.local:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

when I check django, it seems just fine

[30/may/2023:16:12:24] 129 static files copied to '/jp/static'.
[30/may/2023:16:12:26] Operations to perform:
[30/may/2023:16:12:26] Apply all migrations: admin, auth, contenttypes, myprofile, sessions
[30/may/2023:16:12:26] Running migrations:
[30/may/2023:16:12:26] No migrations to apply.
[30/may/2023:16:12:27] [2023-05-30 16:12:27 +0000] [9] [INFO] Starting gunicorn 20.1.0
[30/may/2023:16:12:27] [2023-05-30 16:12:27 +0000] [9] [INFO] Listening at: http://0.0.0.0:8000 (9)
[30/may/2023:16:12:27] [2023-05-30 16:12:27 +0000] [9] [INFO] Using worker: sync
[30/may/2023:16:12:27] [2023-05-30 16:12:27 +0000] [10] [INFO] Booting worker with pid: 10
gefragt vor einem Jahr73 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen