Error creating a connection to Postgresql while preparing konga database

2.4k views Asked by At

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

3

There are 3 answers

0
Doni On

Have you tried like this?

.env

DB_URI=postgresql://userdb:passworddb@localhost:5432/kongadb

I tried on Postgresql 9.6 https://www.rosehosting.com/blog/how-to-install-postgresql-9-6-on-ubuntu-20-04/

0
Matey Aryeh On

Konga has had issues with Postgresql >= 12 for a long time now. I just happened upon a modified docker image for Konga here. The image name is moago/konga_pg14. I just tried it out today and it just works.

All I had to do was map my already existing .env file to the one in the container. Here is a snippet.

volumes:
  - type: bind
    source: .env
    target: /app/.env

Kindly give it a try and let me know how it goes :)

0
Max On

Maybe I overlooked it, but what version of PostreSQL are you using?

Konga is not able to support postgresql 12:

https://github.com/pantsel/konga/issues/487