frontend_1 | 2026/04/09 06:50:53 [error] 30#30: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: , request: "POST /api/users/login HTTP/1.1", upstream: "http://[::1]:3000/api/users/login", host: "localhost:8080", referrer: "http://localhost:8080/login"
frontend_1 | 2026/04/09 06:50:53 [warn] 30#30: *1 upstream server temporarily disabled while connecting to upstream, client: 172.18.0.1, server: , request: "POST /api/users/login HTTP/1.1", upstream: "http://[::1]:3000/api/users/login", host: "localhost:8080", referrer: "http://localhost:8080/login"
frontend_1 | 2026/04/09 06:50:53 [error] 30#30: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: , request: "POST /api/users/login HTTP/1.1", upstream: "http://127.0.0.1:3000/api/users/login", host: "localhost:8080", referrer: "http://localhost:8080/login"
frontend_1 | 2026/04/09 06:50:53 [warn] 30#30: *1 upstream server temporarily disabled while connecting to upstream, client: 172.18.0.1, server: , request: "POST /api/users/login HTTP/1.1", upstream: "http://127.0.0.1:3000/api/users/login", host: "localhost:8080", referrer: "http://localhost:8080/login"
frontend_1 | 172.18.0.1 - - [09/Apr/2026:06:50:53 +0000] "POST /api/users/login HTTP/1.1" 502 157 "http://localhost:8080/login" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0" "-"
docker cp verifywise_frontend_1:/etc/nginx/conf.d/default.conf ./default.conf
proxy_pass http://verifywise_backend_1:3000;
services:
frontend:
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf:ro
The 502 error occurred because localhost inside a Docker container refers strictly to itself,
causing the frontend to search for the API internally instead of using the backend's service name to
communicate across the virtual network.
When I try to log in http://localhost:8080/login.
Error said: Request failed with status code 502.
I set .env.prod.
BACKEND_PORT=3000
BACKEND_URL=http://127.0.0.1:3000/ # localhost needs to be replaced by ip
FRONTEND_PORT=8080
FRONTEND_URL=http://127.0.0.1:8080/ # localhost needs to be replaced by ip
I Final solved by:
vim default.conf
vim docker-compose.yml
The 502 error occurred because localhost inside a Docker container refers strictly to itself,
causing the frontend to search for the API internally instead of using the backend's service name to
communicate across the virtual network.