Konga: ECONNREFUSED : Error: connect ECONNREFUSED 127.0.0.1:8001 konga at TCPConnectWrap.afterConnect as oncomplete

Created on 26 Mar 2020  Â·  2Comments  Â·  Source: pantsel/konga

i am running konga along with docker compose service like kong, postgres, mongo etc. while i can see response on kong admin url i.e http://localhost:8001, but when i try activating the connection from konga ui i get following error in log.

log

konga                 | debug: Policy:dynamicNode `connection-id` is defined. 1
konga                 | debug: KongProxyController:req.method GET
konga                 | debug: KongProxyController:req.url ?connection_id=1
konga                 | debug: KongProxyController:entity null
konga                 | debug: Kong admin url => http://localhost:8001
konga                 | error: KongProxyController request error undefined
konga                 | error: Sending 500 ("Server Error") response: 
konga                 |  { error:
konga                 |    { Error: connect ECONNREFUSED 127.0.0.1:8001
konga                 |        at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
konga                 |      errno: 'ECONNREFUSED',
konga                 |      code: 'ECONNREFUSED',
konga                 |      syscall: 'connect',
konga                 |      address: '127.0.0.1',
konga                 |      port: 8001 } }

my docker-compose.yml file is as follows :

version: "3.3"
services:
  kong-migrations:
    image: "${KONG_DOCKER_TAG:-kong:latest}"
    command: kong migrations bootstrap
    depends_on:
      - db
    environment:
      KONG_DATABASE: postgres
      KONG_PG_DATABASE: kong
      KONG_PG_HOST: db
      KONG_PG_USER: kong
      KONG_PG_PASSWORD: <MY_PASS>
    secrets:
      - kong_postgres_password
    networks:
      - database
    restart: on-failure
    deploy:
      restart_policy:
        condition: on-failure

  kong-migrations-up:
    image: "${KONG_DOCKER_TAG:-kong:latest}"
    command: kong migrations up && kong migrations finish
    depends_on:
      - db
    environment:
      KONG_DATABASE: postgres
      KONG_PG_DATABASE: kong
      KONG_PG_HOST: db
      KONG_PG_USER: kong
      KONG_PG_PASSWORD: <MY_PASS>
    secrets:
      - kong_postgres_password
    networks:
      - database
    restart: on-failure
    deploy:
      restart_policy:
        condition: on-failure

  kong:
    image: "${KONG_DOCKER_TAG:-kong:latest}"
    container_name: kong
    user: "${KONG_USER:-kong}"
    depends_on:
      - db
    environment:
      KONG_ADMIN_ACCESS_LOG: /dev/stdout
      KONG_ADMIN_ERROR_LOG: /dev/stderr
      KONG_ADMIN_LISTEN: '0.0.0.0:8001'
      KONG_CASSANDRA_CONTACT_POINTS: db
      KONG_DATABASE: postgres
      KONG_PG_DATABASE: kong
      KONG_PG_HOST: db
      KONG_PG_USER: kong
      KONG_PROXY_ACCESS_LOG: /dev/stdout
      KONG_PROXY_ERROR_LOG: /dev/stderr
      KONG_PG_PASSWORD: <MY_PASS>
    secrets:
      - kong_postgres_password
    networks:
      - frontend
      - backend
      - database
    ports:
      - 8000:8000
      - 8001:8001
      - 8443:8443
      - 8444:8444
    expose:
      - 8000
      - 8001
      - 8443
      - 8444
    healthcheck:
      test: ["CMD", "kong", "health"]
      interval: 10s
      timeout: 10s
      retries: 10
    restart: on-failure
    deploy:
      restart_policy:
        condition: on-failure

  db:
    image: postgres:9.5
    container_name: kong_db
    environment:
      POSTGRES_DB: kong
      POSTGRES_USER: kong
      POSTGRES_PASSWORD: <MY_PASS>
    secrets:
      - kong_postgres_password
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "${KONG_PG_USER:-kong}"]
      interval: 30s
      timeout: 30s
      retries: 3
    restart: on-failure
    deploy:
      restart_policy:
        condition: on-failure
    stdin_open: true
    tty: true
    networks:
      - database
    volumes:
      - kong_data:/var/lib/postgresql/data

  konga:
    image: 'pantsel/konga:latest'
    container_name: konga
    restart: always
    environment:
      - NODE_ENV=development
      - NODE_TLS_REJECT_UNAUTHORIZED=0
      - KONG_ADMIN_URL=http://kong:8001
      - KONGA_SEED_USER_DATA_SOURCE_FILE=/user_seed.md
    depends_on:
      - kong
    ports:
      - 1337:1337
    expose:
      - 1337
    volumes:
      - ./setup/konga/user_seed.md:/user_seed.md
    networks:
      - backend
      - frontend

  mongodb:
    image: 'mongo:3.6.3'
    container_name: mongodb
    ports:
      - "27017:27017"
    environment:
        MONGO_INITDB_ROOT_USERNAME: mongouser
        MONGO_INITDB_ROOT_PASSWORD: <MY_PASS>
        MONGO_INITDB_DATABASE: traavn
    networks:
      database:
        aliases:
          - mongoserver
    volumes:
          - ./setup/mongo/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro

  webserver:
    image: 'httpd'
    container_name: webserver
    ports:
      - 8080:80
    expose:
      - 8080
    networks:
      - frontend

networks:
  database:
  backend:
  frontend:

volumes:
  kong_data: {}

secrets:
  kong_postgres_password:
    file: ./setup/postgres/POSTGRES_PASSWORD

Docker container status

CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS                      PORTS                                                                NAMES
2eee249b3cdc        pantsel/konga:latest   "/app/start.sh"          14 minutes ago      Up 14 minutes               0.0.0.0:1337->1337/tcp                                               konga
e7284cb0e0a8        kong:latest            "/docker-entrypoint.…"   15 minutes ago      Exited (0) 14 minutes ago                                                                        traavn-services_kong-migrations_1
dc606141d647        kong:latest            "/docker-entrypoint.…"   15 minutes ago      Exited (0) 14 minutes ago                                                                        traavn-services_kong-migrations-up_1
946d1754891c        kong:latest            "/docker-entrypoint.…"   15 minutes ago      Up 14 minutes (healthy)     0.0.0.0:8000-8001->8000-8001/tcp, 0.0.0.0:8443-8444->8443-8444/tcp   kong
0a497f852586        postgres:9.5           "docker-entrypoint.s…"   15 minutes ago      Up 15 minutes (healthy)     5432/tcp                                                             kong_db
b50d3bdd679c        httpd                  "httpd-foreground"       15 minutes ago      Up 15 minutes               8080/tcp, 0.0.0.0:8080->80/tcp                                       webserver
f89606fc73eb        mongo:3.6.3            "docker-entrypoint.s…"   15 minutes ago      Up 15 minutes               0.0.0.0:27017->27017/tcp                                             mongodb

Most helpful comment

If you are running everything in docker you might need to specify the docker containers name that Kong Admin API is running. For instance, http://kong:8001.

If Kong Admin API is not running in docker then you need to expose local host to konga docker run with --network=host.

All 2 comments

If you are running everything in docker you might need to specify the docker containers name that Kong Admin API is running. For instance, http://kong:8001.

If Kong Admin API is not running in docker then you need to expose local host to konga docker run with --network=host.

Closing this due to inactivity. Feel free to reopen if needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nylocx picture nylocx  Â·  3Comments

PichayuthK picture PichayuthK  Â·  4Comments

zhaoJone picture zhaoJone  Â·  8Comments

timpamungkas picture timpamungkas  Â·  6Comments

Ne0nx3r0 picture Ne0nx3r0  Â·  4Comments