Score:0

connect() failed (111: Connection refused) when trying to reach 1 of 3 apps

fr flag

I have two Django apps running on my Debian server with Gunicorn. One running on port 80(app1), the other on 84(app2). app1 is working fine. But when trying to open app2, I get a 502 Bad Gateway from Nginx. Both their configs are almost identical. I have no idea why this isnt working. I also have a third app running but that's running on Flask IIRC.

sites-available/app2

server {
listen 84;
server_name app2;

location / {
    include proxy_params;
    proxy_pass http://127.0.0.1:7000;
}

location /static/ {
    root /home/app1;
    try_files $uri =404;
}
}

sites-available/app1

server {
        listen 80;
        server_name app1;
    
        location / {
            include proxy_params;
            proxy_pass http://127.0.0.1:8000;
        }
    
        location /static/ {
            root /home/django;
            try_files $uri =404;
        }
       location /bestanden/ {
            root /home/django/files;
            add_header Pragma public;
            add_header Cache-Control "public";
        }
    }

/etc/systemd/system/app1.service

[Unit]
Description=App1
After=network.target

[Service]
Type=simple
User=root
ExecStart=/bin/bash /home/app1/bin/start-app.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

/home/app1/bin/start-app1.sh

cd /home/app1/app
echo "Activating"
source /home/app1/env/bin/activate
echo "Starting"
# conf.py contains some environment variables for the app
gunicorn -c "/home/app1/env/bin/gunicorn.conf.py" app1.wsgi

/etc/systemd/system/pricescraper.server

[Unit]
Description=App2
After=network.target

[Service]
Type=simple
User=root
ExecStart=/bin/bash /home/app2/bin/start-app.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

/home/app2/bin/start-app2

cd /home/app2/app/
source /home/app2/venv/bin/activate
gunicorn -c "/home/app2/venv/bin/gunicorn.conf.py" app2.wsgi -b 192.168.188.43:7000

When I take a look at error.log I get this: [error] 1560#1560: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.188.199, server: app2, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:7000/", host: "192.168.188.43:84"

I have no idea what this means, googling it ended up on a question where they were using sockets and just removed the ULR prefix, which doesnt apply to me. The weirdest part is when I open 192.168.188.43:7000 I does open the index.html but without any static files loading, which includes necessary JS so I can't test the backend.

Please, any help appreciated!

Score:1
ru flag

Apparently it wasn't supposed to bind to 192.168... but to 127.0.0.1

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.