problem
Visit nginx 502 bad gateway
connect() failed (111: Connection refused)while connecting to upstream
Possible causes 1 docker network problems
The bridge used by docker nginx container (default), and the forwarded service and nginx are on the same machine, but not in the same container, and nginx.conf proxy_pass
is localhost/127.0.0.1
Solution 1:
proxy_pass
use intranet (starting with 172/10)/public address IP addr
view the address of the machine.
Solution 2:
When starting the nginx container, use --net=host
to specify the same network as the host.
docker run --name some-nginx --net=host -v /home/docker/nginx:/etc/nginx -v /home/docker/nginx/logs:/opt/app/logs -d nginx
Possible question 2 is the service started or not?
Make sure the service starts normally docker ps
check whether the service exists;
Ensure proxy_ The port of pass is consistent with the service port being forwarded. Use telnet IP port
to test
Possible question 3: is the port open
For ECS, if the proxy address is not the local IP address, please open the corresponding port in the corresponding security policy
Similar Posts:
- Fix Nginx 502 Error:upstream sent too big header while reading response header from upstream
- Solving the problem of nginx reverse proxy web service soap:address location problem
- [Solved] Bind for 0.0.0.0:80 failed: port is already allocated
- Vagrant: How to Change the Default SSH Port
- Solution of docker error checking TLS connection
- Nginx error 111: connection rejected [How to Solve]
- Solve the 400 error of nginx forwarding websocket
- Install a docker container in centos7 that can log in SSH
- nginx Server Start Error: nginx: [emerg] open() “/var/run/nginx/nginx.pid” failed (Linux Restart)
- Client IP address forgery, CDN, reverse proxy, access to those things