Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a "host not found in upstream "app:9000" error causing a 502 #313

Closed
alexbarnhill opened this issue Apr 17, 2018 · 3 comments
Closed

Comments

@alexbarnhill
Copy link

I'm using the setup under .examples/docker-compose/with-nginx-proxy/mariadb/fpm/ but using my own instance of nginx-proxy and lets-encrypt-companion. The setup for both of those are practically identical to what is in the docker-compose.yml in this example so I took them out. My current docker-compose.yml is currently this:

version: '3'

services:
  db:
    build: ./db
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=
    env_file:
      - db.env

  app:  
    image: nextcloud:fpm
    restart: always
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MYSQL_HOST=db
    env_file:
      - db.env
    depends_on:
      - db

  web:
    build: ./web
    restart: always
    volumes:
      - nextcloud:/var/www/html:ro
    environment:
      - VIRTUAL_HOST=
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=
      - LETSENCRYPT_EMAIL=
    expose:
      - "80"
    depends_on:
      - app
    networks:
      - nginx-proxy

volumes:
  db:
  nextcloud:
  certs:
  vhost.d:
  html:

networks:
  nginx-proxy:
     external: true

It seems that i can start the containers without issue and they all show up under docker container ls but upon attempting to open the nextcloud page I receive a 502 bad gateway error and in the logs for the app container I see the error nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/nginx.conf:31. The nginx.conf file has not been changed at all. Has anyone else had this issue?

@ptrunk
Copy link

ptrunk commented May 15, 2018

I also had this issue. Have you tried to restart your proxy? nginx does not check the ip of the application container after nginx has started. So if the application conatiner gets a new ip your proxy still tries to connect to the old ip. That was the problem in my case.

@Morgy93
Copy link

Morgy93 commented Aug 3, 2018

I just had the same issue.
I only added the default network to the web service and it finally worked.

@SnowMB
Copy link
Contributor

SnowMB commented Aug 4, 2018

@Morgy93 gave the right answer.

You have to make sure, that the nextcloud-fpm container (app) and the webserver (web) share the same network. Docker compose implicitly adds a network called default to all containers as long as there is none otherwise specified.

The web container has also to be in the proxy network, so that outside connections can reach the service.
Since you have specified a network, you have to manually add the default network to the container.

...
 web:
    build: ./web
    restart: always
    volumes:
      - nextcloud:/var/www/html:ro
    environment:
      - VIRTUAL_HOST=
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=
      - LETSENCRYPT_EMAIL=
    depends_on:
      - app
    networks:
      - nginx-proxy
      - default
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants