I'm currently using cluster mode pm2 and nginx to serve the website. As soon as I deployed a new version with pm2 reload, the website let's say example.com throws 502 bad gateway error. After 10-15s, things become normal and I can access my website.
The error is here
2024/03/25 14:19:48 [error] 22594#22594: *5447 no live upstreams while connecting to upstream, client: 172.71.131.128, server: servers.example.com, request: "OPTIONS /api/serverApi/getServers HTTP/1.1", upstream: "http://servers/api/serverApi/getServers", host: "servers.example.com"
What could be the root problem? I'm stuck here because it functions well after 10-15s. Below is one of my nginx conf file.
upstream websocket {
#least_conn;
#ip_hash;
server 127.0.0.1:1442;
server 127.0.0.1:1443;
# server 127.0.0.1:1444;
# server 127.0.0.1:1445;
keepalive 64;
}
server {
listen 80;
listen [::]:80;
server_name socket.example.com;
location / {
proxy_pass http://websocket;
include /etc/nginx/proxy_params;
proxy_connect_timeout 1m;
proxy_read_timeout 1m;
}
location ^~ /nginx_status {
auth_basic "Admin Login";
auth_basic_user_file /etc/nginx/pma_pass;
stub_status on;
access_log off;
allow example_ip/32;
# deny all;
}
}
I tried adding proxy-timeout but it didn't solve the problem. What can I do more? I want a seamless update instead of 502. It works seamlessly if I go around the website. But if I hard reload F5 the website, it shows 502 for 10-15s.