'Wiki.js not running. Database Connection Error
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!
Solution 1:[1]
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.
Solution 2:[2]
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
Solution 3:[3]
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
Solution 4:[4]
If you need to change the database password, this can help you:
ALTER USER postgres WITH PASSWORD 'xxx';
Solution 5:[5]
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:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | suther |
| Solution 2 | Steven will |
| Solution 3 | Oscar Salazar |
| Solution 4 | Steven will |
| Solution 5 | cursorrux |
