PostgreSQL error

Describe the problem/error/question

I am trying to install n8n community edition and would like to use PostgreSQL database. My database is a managed database hosted with DigitalOcean. When I configure the settings in .env for the PostgreSQL, I get connectivity error

What is the error message (if any)?

Sep 30 02:33:50 dl-prd-n8n-01 n8n[37920]: Initializing n8n process

Sep 30 02:33:50 dl-prd-n8n-01 n8n[37920]: There was an error initializing DB

Sep 30 02:33:50 dl-prd-n8n-01 n8n[37920]: no pg_hba.conf entry for host “10.124.0.10”, user “n8n_user”, database “n8n_prd”, no encryption

Please share your workflow

N.A.

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.113.3
  • Database (default: SQLite): PostgrSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Ubuntu Server
  • Operating system: Ubintu

Below are the settings in my .env file

DB_TYPE=postgresdb

DB_POSTGRESDB_DATABASE=n8n_prd

DB_POSTGRESDB_HOST=n8n_db.ondigitalocean.com

DB_POSTGRESDB_PORT=25565

DB_POSTGRESDB_USER=n8n_db_user

DB_POSTGRESDB_PASSWORD=AVeryStrongPassword

DB_POSTGRESDB_SSL=true

I have also tried with the below settings and with these settings, n8n tries to connect to PostgreSQL on localhost and fails

DB_TYPE=postgresdb

DB_POSTGRESDB_CONNECTION_URL=postgresql://n8n_db_user:AVeryStrongPassword@n8n_db.ondigitalocean.com:25565/n8n_prd?sslmode=require

With the above setting, I get below error
Sep 30 03:07:22 dl-prd-n8n-01 n8n[38431]: Initializing n8n process

Sep 30 03:07:23 dl-prd-n8n-01 n8n[38431]: There was an error initializing DB

Sep 30 03:07:23 dl-prd-n8n-01 n8n[38431]: connect ECONNREFUSED ::1:5432

What am I missing here? Any help is greatly appreciated.

I tried to update the settings in .env to match from this post and it still connects to the local SQLite database.

Found the solution.

I had to add below setting to my .env file and it worked after that.

DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED=false

1 Like