konga
konga copied to clipboard
Error creating a connection to Postgresql while preparing konga database
After installing Konga, we are trying to prepare Konga database on the already running Postgresql database. by using suggested command i.e.
node ./bin/konga.js prepare --adapter postgres --uri postgresql://localhost:5432/konga
But we are facing the error as below:
Error creating a connection to Postgresql using the following settings:
postgresql://localhost:5432/konga?host=localhost&port=5432&schema=true&ssl=false&adapter=sails-postgresql&user=postgres&password=XXXX&database=konga_database&identity=postgres
* * *
Complete error details:
error: password authentication failed for user "root"
error: A hook (`orm`) failed to load!
error: Failed to prepare database: error: password authentication failed for user "root"
We even created the schema konga_database
manually and have tried several variations for prepare command but no fate
node ./bin/konga.js prepare --adapter postgres --uri postgresql://kong:XXXX@localhost:5432/konga_database
node ./bin/konga.js prepare --adapter postgres --uri postgresql://kong@localhost:5432/konga
node ./bin/konga.js prepare --adapter postgres --uri postgresql://kong@localhost:5432/konga_database
Below is config/connections.js
postgres: {
adapter: 'sails-postgresql',
url: process.env.DB_URI,
host: process.env.DB_HOST || 'localhost',
user: process.env.DB_USER || 'postgres',
password: process.env.DB_PASSWORD || 'XXXX',
port: process.env.DB_PORT || 5432,
database: process.env.DB_DATABASE ||'konga_database',
// schema: process.env.DB_PG_SCHEMA ||'public',
// poolSize: process.env.DB_POOLSIZE || 10,
ssl: process.env.DB_SSL ? true : false // If set, assume it's true
},
Below is .env file configuration
PORT=1337
NODE_ENV=production
KONGA_HOOK_TIMEOUT=120000
DB_ADAPTER=postgres
DB_URI=postgresql://localhost:5432/konga
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=XXXX
KONGA_LOG_LEVEL=info
TOKEN_SECRET=
kong and postgresql are already running on the AWS linux AMI 2 server on there respective ports i.e. 8443 & 5432
Please help us to prepare DB and start konga service. Also. let us know in case you need more info.
Node v: v12.19.0 NPM v: 6.14.8
Regards Nitin G
@nitin194 did you find any solution for it?
Not yet .... but you can use below Docker-compose file to run all at once.
`version: "3.7"
volumes: kong_data: {}
networks: kong-net:
services:
#######################################
Postgres: The database used by Kong
####################################### kong-database: image: postgres:9.6 container_name: kong-postgres restart: on-failure networks: - kong-net volumes: - kong_data:/var/lib/postgresql/data environment: POSTGRES_USER: kong POSTGRES_PASSWORD: ${KONG_PG_PASSWORD:-kong} POSTGRES_DB: kong ports: - "5432:5432" healthcheck: test: ["CMD", "pg_isready", "-U", "kong"] interval: 30s timeout: 30s retries: 3
#######################################
Kong database migration
####################################### kong-migration: image: ${KONG_DOCKER_TAG:-kong:latest} command: kong migrations bootstrap networks: - kong-net restart: on-failure environment: KONG_DATABASE: postgres KONG_PG_HOST: kong-database KONG_PG_DATABASE: kong KONG_PG_USER: kong KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong} depends_on: - kong-database
#######################################
Kong: The API Gateway
####################################### kong: image: ${KONG_DOCKER_TAG:-kong:latest} restart: on-failure networks: - kong-net environment: KONG_DATABASE: postgres KONG_PG_HOST: kong-database KONG_PG_DATABASE: kong KONG_PG_USER: kong KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong} KONG_PROXY_LISTEN: 0.0.0.0:8000 KONG_PROXY_LISTEN_SSL: 0.0.0.0:8443 KONG_ADMIN_LISTEN: 0.0.0.0:8001 depends_on: - kong-database healthcheck: test: ["CMD", "kong", "health"] interval: 10s timeout: 10s retries: 10 ports: - "8000:8000" - "8001:8001" - "8443:8443" - "8444:8444"
#######################################
Konga database prepare
####################################### konga-prepare: image: pantsel/konga:latest command: "-c prepare -a postgres -u postgresql://kong:${KONG_PG_PASSWORD:-kong}@kong-database:5432/konga" networks: - kong-net restart: on-failure depends_on: - kong-database
#######################################
Konga: Kong GUI
#######################################
konga:
image: pantsel/konga:latest
restart: always
networks:
- kong-net
environment:
DB_ADAPTER: postgres
DB_URI: postgresql://kong:${KONG_PG_PASSWORD:-kong}@kong-database:5432/konga
NODE_ENV: production
depends_on:
- kong-database
ports:
- "1337:1337"`
Same here.
Any solution?
Only my last comment is the solution with me
Seems this is correct format postgresql://username:password@localhost
node ./bin/konga.js prepare --adapter postgres --uri "postgresql://kong:kong@localhost:5432/konga_db?host=localhost&port=5432&user=kong&password=kong"
Also you have to use PostgreSQL <12, due this https://github.com/pantsel/konga/issues/649#issuecomment-952998180 Docker image is using 9.6.