N8N -> Postgres via CloudSQL auth Proxy ECONNREFUSED

I’m trying to run N8N with a postgres DB hosted in GCP Cloud SQL. Doing so requires using Cloud SQL Auth Proxy which I have setup accordingly. I can connect to the DB using Datagrip and ./pg_isready -h localhost -d n8n -p 5432 -U postgres returns no errors.

However when running npx n8n locally with the following envs (password removed)

DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_HOST=localhost
DB_POSTGRESDB_PORT=5432
DB_POSTGRESDB_USER=postgres
DB_POSTGRESDB_PASSWORD=
DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED=false

it fails to connect to the DB

Initializing n8n process
Error: There was an error initializing DB
Error: connect ECONNREFUSED ::1:5432

Is there something missing?

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
  • n8n version: 1.63.4
  • Database (default: SQLite): postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: OSX

hello @Mythrandil

Have you tried to connect to the agent via 127.0.0.1 ? I see the n8n is trying to access it via IPv6 protocol, that may be not working

Thanks, that worked perfectly once I removed DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED env variable!

I can now run n8n locally connected to my CloudSQL in GCP.

My next problem I have is the same env settings doesn’t work in Google Cloud Run which should work exactly the same with the Cloud SQL proxy

2024-10-18 12:34:36.109 PDT
Initializing n8n process
2024-10-18 12:34:37.013 PDT
Error: There was an error initializing DB
2024-10-18 12:34:38.137 PDT
Error: connect ECONNREFUSED 127.0.0.1:5432

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.