Wiki.js not running. Database Connection Error
Asked Answered
L

8

10

Windows Enterprise 2016 LTSB Version 1607. Installed Wiki.js with PostgreSQL. Has Node.js installed previously (v12.16.2).

Got to step 8 of wiki.js installation process using the Powershell:

node server

I receive this error:

PS C:\wiki> node server
Loading configuration from C:\wiki\config.yml... OK
2021-01-03T23:06:14.299Z [MASTER] info: =======================================
2021-01-03T23:06:14.300Z [MASTER] info: = Wiki.js 2.5.170 =====================
2021-01-03T23:06:14.301Z [MASTER] info: =======================================
2021-01-03T23:06:14.301Z [MASTER] info: Initializing...
2021-01-03T23:06:14.688Z [MASTER] info: Using database driver pg for postgres [ OK ]
2021-01-03T23:06:14.690Z [MASTER] info: Connecting to database...
2021-01-03T23:06:15.698Z [MASTER] error: Database Connection Error: ECONNREFUSED 127.0.0.1:5432
2021-01-03T23:06:15.698Z [MASTER] warn: Will retry in 3 seconds... [Attempt 1 of 10]
2021-01-03T23:06:18.700Z [MASTER] info: Connecting to database...
2021-01-03T23:06:19.703Z [MASTER] error: Database Connection Error: ECONNREFUSED 127.0.0.1:5432
2021-01-03T23:06:19.703Z [MASTER] warn: Will retry in 3 seconds... [Attempt 2 of 10]
... (you get the point)
2021-01-03T23:06:51.728Z [MASTER] error: Database Connection Error: ECONNREFUSED 127.0.0.1:5432
2021-01-03T23:06:51.729Z [MASTER] warn: Will retry in 3 seconds... [Attempt 10 of 10]
2021-01-03T23:06:54.730Z [MASTER] info: Connecting to database...
2021-01-03T23:06:55.733Z [MASTER] error: Database Initialization Error: connect ECONNREFUSED 127.0.0.1:5432

I realize that I forgot to create a PostgreSQL, so I used pgAdmin4.28 to create a "wiki" database. Error now changed to:

PS C:\wiki> node server
Loading configuration from C:\wiki\config.yml... OK
2021-01-04T00:27:21.979Z [MASTER] info: =======================================
2021-01-04T00:27:21.980Z [MASTER] info: = Wiki.js 2.5.170 =====================
2021-01-04T00:27:21.981Z [MASTER] info: =======================================
2021-01-04T00:27:21.982Z [MASTER] info: Initializing...
2021-01-04T00:27:22.363Z [MASTER] info: Using database driver pg for postgres [ OK ]
2021-01-04T00:27:22.365Z [MASTER] info: Connecting to database...
2021-01-04T00:27:22.428Z [MASTER] error: Database Connection Error: 28P01 undefined:undefined
2021-01-04T00:27:22.429Z [MASTER] warn: Will retry in 3 seconds... [Attempt 1 of 10]
2021-01-04T00:27:25.431Z [MASTER] info: Connecting to database...
2021-01-04T00:27:25.501Z [MASTER] error: Database Connection Error: 28P01 undefined:undefined
2021-01-04T00:27:25.501Z [MASTER] warn: Will retry in 3 seconds... [Attempt 2 of 10]
2021-01-04T00:27:28.503Z [MASTER] info: Connecting to database...
2021-01-04T00:27:28.545Z [MASTER] error: Database Connection Error: 28P01 undefined:undefined
2021-01-04T00:27:28.546Z [MASTER] warn: Will retry in 3 seconds... [Attempt 3 of 10]

Please send help! I appreciate all comments. Thanks!

Leptophyllous answered 4/1, 2021 at 6:20 Comment(1)
dw guys, I'll keep my pc online until this issue is resolvedLeptophyllous
D
6

I had similar issue with postgres and wiki.js. Solution was to manually create the Database in postgres, BEFORE you run node server:

CREATE DATABASE wiki

Hope that saves you the time I had to spend to figure this out.

Defend answered 21/5, 2021 at 7:17 Comment(0)
R
4

My environment is as follows: Windows 10 professional version number 20h2 node version v14.15.4 PostgreSQL V 13.1, the error content is as follows:

Loading configuration from D:\dev\workspace\wiki\config.yml... OK
2021-02-03T06:32:55.015Z [MASTER] info: =======================================
2021-02-03T06:32:55.016Z [MASTER] info: = Wiki.js 2.5.170 =====================
2021-02-03T06:32:55.016Z [MASTER] info: =======================================
2021-02-03T06:32:55.017Z [MASTER] info: Initializing...
2021-02-03T06:32:59.091Z [MASTER] info: Using database driver pg for postgres [ OK ]
2021-02-03T06:32:59.094Z [MASTER] info: Connecting to database...
2021-02-03T06:32:59.160Z [MASTER] error: Database Connection Error: 28P01 
undefined:undefined

You just need to config.yml The database configuration in is modified as follows:

db:
  type: postgres

  # PostgreSQL / MySQL / MariaDB / MS SQL Server only:
  host: localhost
  port: 5432
  user: postgres #YOU PostgreSQL USERNAME
  pass: willasas@wiki. #YOU PostgreSQL PASSWORD
  db: wiki #YOU DATABASE NAME
  ssl: false

Then run the code

node server

And type in the address bar of your browser http://127.0.0.1 : 3000 / parallel return

Rebellious answered 3/2, 2021 at 7:49 Comment(0)
B
1

After a couple hours of testing I realized some problems using postgres in wiki.js. These are some recommendations you can try in config.yml:

db:
  type: postgres
  
  # if you are using docker try using IP instead of localhost
  host: localhost
  port: 5432
  
  # don't use _ here. It'll cause connection error undefined.
  user: wikijs
  
  # start with letter, if you start with @ it will throw an error.
  # I used a 18 long pass without any problem. Ex:
  pass: wiki@projectW777!@
  
  # you can use _ here. Ex:
  db: prj_wiki
Blockbusting answered 14/1, 2021 at 17:46 Comment(0)
R
1

If you need to change the database password, this can help you:

ALTER USER postgres WITH PASSWORD 'xxx';
Rebellious answered 3/2, 2021 at 7:53 Comment(0)
N
1

I had the same problem:

error: Database Connection Error: 28P01 undefined:undefined

I've solved it by modifying 86 line of file /var/lib/psql/data/pg_hba.conf, changing ident to md5 and then restarted database:

$ sudo systemctl restart postgresql

Additionally I've changed password in database:

$ sudo -u wikijs psql -d wiki
wiki=# \password wikijs

After that I've successfully executed node server.

Nanette answered 29/6, 2022 at 11:13 Comment(0)
S
0

Use this docker-compose file.

It solved my problems. Also make sure all the service names are unique, i.e. neither of the exist in your presently running docker containers

version: '3'
services:
  db:
    image: mysql:8.0
    logging:
      driver: "none"
    restart: unless-stopped
    volumes:
      - db-data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: mysql123!
      MYSQL_DATABASE: wiki

  wiki:
    image: requarks/wiki:2
    depends_on:
      - db
    environment:
      DB_TYPE: mysql
      DB_HOST: db
      DB_PORT: 3307
      DB_USER: root
      DB_PASS: mysql123!
      DB_NAME: wiki
    restart: unless-stopped
    ports:
      - "9010:3000"

volumes:
  db-data:

If you rename the "db" service name, make sure to update the "DB_HOST" environment parameter too !!

Stethoscope answered 22/3, 2022 at 9:38 Comment(0)
F
0

My Error Message was as followed:

Loading configuration from /wiki/config.yml... OK
2023-03-22T08:17:20.443Z [MASTER] info: =======================================
2023-03-22T08:17:20.445Z [MASTER] info: = Wiki.js 2.5.298 =====================
2023-03-22T08:17:20.445Z [MASTER] info: =======================================
2023-03-22T08:17:20.445Z [MASTER] info: Initializing...
2023-03-22T08:17:21.095Z [MASTER] info: Using database driver pg for postgres [ OK ]
2023-03-22T08:17:21.108Z [MASTER] info: Connecting to database...
2023-03-22T08:17:21.130Z [MASTER] error: Database Connection Error: ENOTFOUND undefined:undefined
2023-03-22T08:17:21.130Z [MASTER] warn: Will retry in 3 seconds... [Attempt 1 of 10]
2023-03-22T08:17:24.135Z [MASTER] info: Connecting to database...
2023-03-22T08:17:24.138Z [MASTER] error: Database Connection Error: ENOTFOUND undefined:undefined
2023-03-22T08:17:24.138Z [MASTER] warn: Will retry in 3 seconds... [Attempt 2 of 10]

And the solution/problem for me was the encoded Password in the secret.

I used echo "VH43GmpYEMk9" | base64 which produced: Vkg0M0dtcFlFTWs5Cg==

You have to get rid of Cg== which is apparently the base64 encode of the new line character in the latest position.

So instead I had to use this encoded string: Vkg0M0dtcFlFTWs5

And just for reference this is how I ended up installing wiki.js:

helm install wiki-postgresql bitnami/postgresql -n wiki --set auth.username="wiki" --set auth.password="VH43GmpYEMk9 " --set auth.database="wiki" --set auth.postgresPassword="VH43GmpYEMk9 "
apiVersion: v1
data:
  postgresql-password: Vkg0M0dtcFlFTWs5 # VH43GmpYEMk9 in base64 encoded
kind: Secret
metadata:
  name: wiki
  namespace: wiki
type: Opaque
helm repo add requarks https://charts.js.wiki

helm repo update

helm install wiki requarks/wiki -n wiki --set postgresql.enabled=false --set postgresql.postgresqlHost=wiki-postgresql.wiki.svc.cluster.local --set postgresql.existingSecret=wiki --set postgresql.postgresqlUser=wiki
Fraser answered 22/3, 2023 at 12:42 Comment(0)
G
0

If anyone getting these errors and using Azure for deployment:

error: Database Connection Error: 28P01 

Database Connection Error: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

You have to pay attention what database settings you config during Postgresql deployment:

  • If you used Flexible server as deployment you need to provide the username the following way in your Web App --> DB_USER = username@hostname

  • If you deployed your db Single server mode, you only need to provide it like this --> DB_USER = username.

Gregoor answered 29/3, 2023 at 13:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.