Host not found in upstream "backend:8000" with ERPNext on docker

I’m trying to install ERPNEXT on Docker. Every container seems to works fine except for the frontend container.

When inspecting the logs of this container I found

host not found in upstream "backend:8000" in /etc/nginx/conf.d/frappe.conf:2
nginx: [emerg] host not found in upstream "backend:8000" in /etc/nginx/conf.d/frappe.conf:2

This is my compose.yml file:

name: erpnext
services:
  backend:
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext:v14.27.0
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
  backup:
    command:
    - |
      bench --site erpnext.consigliomarco.it backup --with-files --compress
    entrypoint:
    - bash
    - -c
    image: frappe/erpnext:v14.27.0
    networks:
      erpnext-network: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
  configurator:
    command:
    - |
      ls -1 apps > sites/apps.txt; bench set-config -g db_host $$DB_HOST; bench set-config -gp db_port $$DB_PORT; bench set-config -g redis_cache "redis://$$REDIS_CACHE"; bench set-config -g redis_queue "redis://$$REDIS_QUEUE"; bench set-config -g redis_socketio "redis://$$REDIS_SOCKETIO"; bench set-config -gp socketio_port $$SOCKETIO_PORT;
    depends_on:
      db:
        condition: service_healthy
      redis-cache:
        condition: service_started
      redis-queue:
        condition: service_started
      redis-socketio:
        condition: service_started
    entrypoint:
    - bash
    - -c
    environment:
      DB_HOST: db
      DB_PORT: "3306"
      REDIS_CACHE: redis-cache:6379
      REDIS_QUEUE: redis-queue:6379
      REDIS_SOCKETIO: redis-socketio:6379
      SOCKETIO_PORT: "9000"
    image: frappe/erpnext:v14.27.0
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
  db:
    command:
    - --character-set-server=utf8mb4
    - --collation-server=utf8mb4_unicode_ci
    - --skip-character-set-client-handshake
    - --skip-innodb-read-only-compressed
    environment:
      MYSQL_ROOT_PASSWORD: xxxxxxxxxxx
    healthcheck:
      test:
      - CMD-SHELL
      - mysqladmin ping -h localhost --password=xxxxxxxxxxx
      interval: 1s
      retries: 15
    image: mariadb:10.6
    networks:
      default: null
    volumes:
    - type: volume
      source: db-data
      target: /var/lib/mysql
      volume: {}
  frontend:
    command:
    - nginx-entrypoint.sh
    depends_on:
      backend:
        condition: service_started
      websocket:
        condition: service_started
    environment:
      BACKEND: backend:8000
      CLIENT_MAX_BODY_SIZE: 50m
      FRAPPE_SITE_NAME_HEADER: erpnext.consigliomarco.it
      PROXY_READ_TIMOUT: "120"
      SOCKETIO: websocket:9000
      UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
      UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
      UPSTREAM_REAL_IP_RECURSIVE: "off"
    image: frappe/erpnext:v14.27.0
    labels:
      traefik.enable: "true"
      traefik.http.routers.frontend-http.entrypoints: websecure
      traefik.http.routers.frontend-http.rule: Host(`erpnext.consigliomarco.it`)
      traefik.http.routers.frontend-http.tls.certresolver: main-resolver
      traefik.http.services.frontend.loadbalancer.server.port: "8080"
    networks:
      default: null
    ports:
    - mode: ingress
      target: 8080
      published: "8080"
      protocol: tcp
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
  proxy:
    command:
    - --providers.docker=true
    - --providers.docker.exposedbydefault=false
    - --entrypoints.web.address=:9080
    - --entrypoints.web.http.redirections.entrypoint.to=websecure
    - --entrypoints.web.http.redirections.entrypoint.scheme=https
    - --entrypoints.websecure.address=:1443
    - --certificatesResolvers.main-resolver.acme.httpChallenge=true
    - --certificatesResolvers.main-resolver.acme.httpChallenge.entrypoint=web
    - --certificatesResolvers.main-resolver.acme.email=mrccnsgl@gmail.com
    - --certificatesResolvers.main-resolver.acme.storage=/letsencrypt/acme.json
    image: traefik:2.5
    networks:
      default: null
    ports:
    - mode: ingress
      target: 80
      published: "9080"
      protocol: tcp
    - mode: ingress
      target: 443
      published: "1443"
      protocol: tcp
    volumes:
    - type: volume
      source: cert-data
      target: /letsencrypt
      volume: {}
    - type: bind
      source: /var/run/docker.sock
      target: /var/run/docker.sock
      read_only: true
      bind:
        create_host_path: true
  queue-default:
    command:
    - bench
    - worker
    - --queue
    - default
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext:v14.27.0
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
  queue-long:
    command:
    - bench
    - worker
    - --queue
    - long
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext:v14.27.0
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
  queue-short:
    command:
    - bench
    - worker
    - --queue
    - short
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext:v14.27.0
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
  redis-cache:
    image: redis:6.2-alpine
    networks:
      default: null
    volumes:
    - type: volume
      source: redis-cache-data
      target: /data
      volume: {}
  redis-queue:
    image: redis:6.2-alpine
    networks:
      default: null
    volumes:
    - type: volume
      source: redis-queue-data
      target: /data
      volume: {}
  redis-socketio:
    image: redis:6.2-alpine
    networks:
      default: null
    volumes:
    - type: volume
      source: redis-socketio-data
      target: /data
      volume: {}
  scheduler:
    command:
    - bench
    - schedule
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext:v14.27.0
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
  websocket:
    command:
    - node
    - /home/frappe/frappe-bench/apps/frappe/socketio.js
    depends_on:
      configurator:
        condition: service_completed_successfully
    image: frappe/erpnext:v14.27.0
    networks:
      default: null
    volumes:
    - type: volume
      source: sites
      target: /home/frappe/frappe-bench/sites
      volume: {}
networks:
  default:
    name: erpnext_default
  erpnext-network:
    name: erpnext_default
    external: true
volumes:
  cert-data:
    name: erpnext_cert-data
  db-data:
    name: erpnext_db-data
  redis-cache-data:
    name: erpnext_redis-cache-data
  redis-queue-data:
    name: erpnext_redis-queue-data
  redis-socketio-data:
    name: erpnext_redis-socketio-data
  sites:
    name: erpnext_sites
    external: true
x-backend-defaults:
  depends_on:
    configurator:
      condition: service_completed_successfully
  image: frappe/erpnext:v14.27.0
  volumes:
  - sites:/home/frappe/frappe-bench/sites
x-customizable-image:
  image: frappe/erpnext:v14.27.0
x-depends-on-configurator:
  depends_on:
    configurator:
      condition: service_completed_successfully

I think it is some port problem. That’s why I checked the server firewall:

22                         ALLOW IN    Anywhere
80                         ALLOW IN    Anywhere
443                        ALLOW IN    Anywhere
20/tcp                     ALLOW IN    Anywhere
990/tcp                    ALLOW IN    Anywhere
22/tcp (OpenSSH)           ALLOW IN    Anywhere
20,21,10000:10100/tcp      ALLOW IN    Anywhere
22,25,80,143,443,3306,8000/tcp ALLOW IN    Anywhere
25/tcp (Postfix)           ALLOW IN    Anywhere
22 (v6)                    ALLOW IN    Anywhere (v6)
80 (v6)                    ALLOW IN    Anywhere (v6)
443 (v6)                   ALLOW IN    Anywhere (v6)
20/tcp (v6)                ALLOW IN    Anywhere (v6)
990/tcp (v6)               ALLOW IN    Anywhere (v6)
22/tcp (OpenSSH (v6))      ALLOW IN    Anywhere (v6)
20,21,10000:10100/tcp (v6) ALLOW IN    Anywhere (v6)
22,25,80,143,443,3306,8000/tcp (v6) ALLOW IN    Anywhere (v6)
25/tcp (Postfix (v6))      ALLOW IN    Anywhere (v6)

I tried to change default port for proxy and https protocol. Is it breaking something?
Does anyone know if I have to open port 8000 in order to get the frontend working?
I don’t know how to proceed with a further diagnosis.
Any suggestions are appreciated! Thanks.

  • backend container runs gunicorn on port 8000. To change that port you’ve to override the default gunicorn command with your custom one with custom port.
  • websocket container runs on port 9000, picks from common_site_config.json
  • frontend container reverse proxy gunicorn 8000 and socketio 9000. Both these host/port settings are passed as env var to frontend container.
  • both containers must be running and must be accessible to frontend container to or it will fail to start frontend container.

you can tweak the above to customize ports you need.

1 Like