docker icon indicating copy to clipboard operation
docker copied to clipboard

nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/conf.d/default.conf:2

Open PavanYadala opened this issue 7 years ago • 4 comments

On running the docker-compose on AWS ECS, the system is throwing below error. Please let me know how to fix it?

nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/conf.d/default.conf:2

PavanYadala avatar Oct 04 '19 13:10 PavanYadala

I've setup a fresh instance as well with the example docker-compose.yml file (slightly modificated for my use cases ;) ) The problem is, that you need to tell the nginx container to depend on the app container:

web:
  image: nginx:alpine
  depends_on:
    - app
  volumes:
  - ./matomo.conf:/etc/nginx/conf.d/default.conf:ro

@PavanYadala hope this helps you getting started :)

renepardon avatar Oct 18 '19 19:10 renepardon

I have same issue i tried above setup but getting same issue

GopiPacha1996 avatar Feb 13 '20 05:02 GopiPacha1996

There are several reasons for this error. One solution is already mentioned by @renepardon. If you add the depends_on flag and still got the error, check if you renamed your matomo app service. If it looks like this:

services:
  my-matomo-db:
    image: mariadb

  # [...]

  my-matomo-app:
    image: matomo:fpm-alpine

  # [...]

  my-matomo-web:
    image: nginx:alpine

Than you have to also adjust the matomo.conf file. In this case, change the first part into:

upstream php-handler {
	server my-matomo-app:9000;
}

The important thing is that my-matomo-app has to be the same service name as defined in your docker-compose.yml file.

mhellmeier avatar Nov 22 '20 17:11 mhellmeier

None of the above infos worked for me. I was stuck with the port 9000 message. Here's how I fixed it:

Add to the end of the block for app: and web:

networks:
      - backend

Add as suggested by @renepardon to web:

depends_on:
      - app

Add to the end of the compose file

networks:
  backend:
    driver: bridge

m1d1 avatar Jun 28 '21 14:06 m1d1