question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no live upstreams while connecting to upstream

See original GitHub issue

I am trying to run an image using the nginx-proxy image. I created the following docker-compose.yml file to make executing the commands easier

version: '3.4'
services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - 80:80
      - 443:443
    restart: always
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /etc/certificates:/etc/nginx/certs

  private_package_name:
    image: crestapps/private_package_name:latest
    container_name: private_package_name
    command: tail -f /dev/null
    environment:
      - VIRTUAL_HOST=private_package_name.crestapps.com
      - VIRTUAL_PORT=51736
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - 51736:80
      - 44344:443
    volumes:
      - /app/storage:/storage

When I run docker-compose up, both apps run as expected. However, when I make a request to https://private_package_name.crestapps.com I get

502 Bad Gateway

When I look at the logs I see the following

nginx-proxy          | nginx.1    | 2020/01/20 23:49:40 [error] 42#42: *1 no live upstreams while connecting to upstream, client: PersonalIpAddress, server: private_package_name.crestapps.com, request: "GET / HTTP/2.0", upstream: "http://private_package_name.crestapps.com/", host: "private_package_name.crestapps.com"
nginx-proxy          | nginx.1    | private_package_name.crestapps.com PersonalIpAddress - - [20/Jan/2020:23:49:40 +0000] "GET / HTTP/2.0" 502 157 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
nginx-proxy          | nginx.1    | 2020/01/20 23:49:41 [error] 42#42: *1 no live upstreams while connecting to upstream, client: PersonalIpAddress, server: private_package_name.crestapps.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://private_package_name.crestapps.com/favicon.ico", host: "private_package_name.crestapps.com"
nginx-proxy          | nginx.1    | private_package_name.crestapps.com PersonalIpAddress - - [20/Jan/2020:23:49:41 +0000] "GET /favicon.ico HTTP/2.0" 502 157 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"

When I execute docker ps I get the following

CONTAINER ID        IMAGE                                COMMAND                  CREATED              STATUS              PORTS                                           NAMES
d661d4bff1f3        crestapps/private_package_name:latest   "tail -f /dev/null"      9 seconds ago        Up 6 seconds        0.0.0.0:51736->80/tcp, 0.0.0.0:44344->443/tcp   private_package_name
0bd0da4141f8        jwilder/nginx-proxy                  "/app/docker-entrypo…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp        nginx-proxy

running docker logs nginx-proxy gives me the following

WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one
is being generated in the background.  Once the new dhparam.pem is in place, nginx will be reloaded.
forego     | starting dockergen.1 on port 5000
forego     | starting nginx.1 on port 5100
dockergen.1 | 2020/01/21 00:00:51 Generated '/etc/nginx/conf.d/default.conf' from 2 containers
dockergen.1 | 2020/01/21 00:00:51 Watching docker events
dockergen.1 | 2020/01/21 00:00:51 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
2020/01/21 00:01:08 [notice] 53#53: signal process started
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
dhparam generation complete, reloading nginx
dockergen.1 | 2020/01/21 00:02:27 Received event die for container 274d6e739fd8
dockergen.1 | 2020/01/21 00:02:29 Received event stop for container 274d6e739fd8
dockergen.1 | 2020/01/21 00:02:29 Generated '/etc/nginx/conf.d/default.conf' from 1 containers
dockergen.1 | 2020/01/21 00:02:30 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
dockergen.1 | 2020/01/21 00:02:33 Received event start for container d661d4bff1f3
dockergen.1 | 2020/01/21 00:02:33 Generated '/etc/nginx/conf.d/default.conf' from 2 containers
dockergen.1 | 2020/01/21 00:02:33 Running 'nginx -s reload'

running docker logs private_package_name gives me nothing.

Is there something I am doing wrong here or is this some sort of a bug? Help would me much appreciated.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
hacker-hcommented, Jun 7, 2020

The VIRTUAL_PORT has to match the port within your target container (80 in your case). It has nothing to do with the port mappings you declare using the ports list, you do not even have to do any port mappings if you want to access your container merely via proxy.

1reaction
Liljacommented, May 1, 2020

I had the same issue and I added EXPOSE <port> to my Dockerfile, it worked thereafter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nginx : no live upstreams while connecting to upstream
load balancing configured on two upstreams php1 php2 both are apache server. When I checked error log i fond: no live upstreams while...
Read more >
How to solve nginx - no live upstreams while connecting to ...
After sending 20k request per second I got “no live upstreams while connecting to upstream client” in nginx error log.
Read more >
"no live upstreams while connecting to upstream" Error , Nginx ...
There is a persistent error ever since I upgraded to php8.1 and added a new connection to the upstream of the load balancer....
Read more >
Including "down" server entries can lead to "no live upstreams ...
However, nginx actually has a fallback case that when an upstream only has one server listed, then it skips the "no live upstreams"...
Read more >
NGINX no live upstreams while connecting - OPNsense Forum
Re: NGINX no live upstreams while connecting​​ Syntax seems fine now. No more error, but... *9 no live upstreams while connecting to upstream, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found