Docker Compose nodebb + postgres | Error connecting to database
Unsolved
Technical Support
-
Hi all! Super excited to give nodebb a try.
I'm trying to set up nodebb using docker compose and Postgres as my database. However, I always encounter the "There was an error connecting to your database. Please try again." error when trying to setup using the NodeBB installer.
The logs read
2024-03-08 14:05:21 Welcome to NodeBB v1.19.7! 2024-03-08 14:05:21 2024-03-08 14:05:21 This looks like a new installation, so you'll have to answer a few questions about your environment before we can proceed. 2024-03-08 14:05:21 Press enter to accept the default setting (shown in brackets). 2024-03-08 14:05:21 2024-03-08T06:05:21.169Z [30] - info: [install/checkSetupFlagEnv] checking env vars for setup info... 2024-03-08 14:05:21 2024-03-08T06:05:21.209Z [30] - info: 2024-03-08 14:05:21 Now configuring postgres database: 2024-03-08 14:05:21 2024-03-08T06:05:21.217Z [30] - warn: NodeBB Setup Aborted. **2024-03-08 14:05:21 Error: connect ECONNREFUSED 127.0.0.1:5432** 2024-03-08 14:05:21 at /usr/src/app/node_modules/pg-pool/index.js:45:11 2024-03-08 14:05:21 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 2024-03-08 14:05:21 at async postgresModule.init (/usr/src/app/src/database/postgres.js:54:17) 2024-03-08 14:05:21 at async completeConfigSetup (/usr/src/app/src/install.js:201:2) 2024-03-08 14:05:21 at async setupConfig (/usr/src/app/src/install.js:186:2) 2024-03-08 14:05:21 at async install.setup (/usr/src/app/src/install.js:562:3) 2024-03-08 14:05:21 at async Object.setup (/usr/src/app/src/cli/setup.js:23:15)
My current dockercompose file reads
version: '3.9' services: nodebb: image: nodebb/docker restart: unless-stopped environment: - DATABASE_URL=postgres://postgres:password@db:5432/postgres volumes: - ./data/nodebb:/data ports: - "4567:4567" db: image: postgres restart: always # set shared memory limit when using docker-compose shm_size: 128mb # or set shared memory limit when deploy via swarm stack volumes: - './data:/data/db' environment: POSTGRES_DB: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: password expose: - "5432" ports: - "5432:5432" adminer: image: adminer restart: always ports: - 8080:8080
This is the DB configuration on the setup page:
If anyone with docker knowledge can help, it'd be great!!
-
@Wong-Jiong-Yu Is your Postgres install listening on port
5432
and127.0.0.1
? -
@phenomlab Hi Phenomlab! This is the log from the Postgres container
2024-03-09 12:30:28 initdb: warning: enabling "trust" authentication for local connections 2024-03-09 12:30:28 initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. 2024-03-09 12:30:28 2024-03-09 04:30:28.666 UTC [1] LOG: starting PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-03-09 12:30:28 2024-03-09 04:30:28.667 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-03-09 12:30:28 2024-03-09 04:30:28.667 UTC [1] LOG: listening on IPv6 address "::", port 5432 2024-03-09 12:30:28 2024-03-09 04:30:28.682 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-03-09 12:30:28 2024-03-09 04:30:28.697 UTC [62] LOG: database system was shut down at 2024-03-09 04:30:28 UTC 2024-03-09 12:30:28 2024-03-09 04:30:28.711 UTC [1] LOG: database system is ready to accept connections
I've changed the configuration to 0.0.0.0 but it still gives the same error
Copyright © 2024 NodeBB | Contributors