# N8N -\> Postgres via CloudSQL auth Proxy ECONNREFUSED

**URL:** <https://community.n8n.io/t/n8n-postgres-via-cloudsql-auth-proxy-econnrefused/58326>\
**Category:** Questions\
**Created:** [17 أكتوبر 2024، 9:29م UTC](https://community.n8n.io/t/n8n-postgres-via-cloudsql-auth-proxy-econnrefused/58326 "2024-10-17T21:29:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mythrandil](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mythrandil/32/46691_2.png) [@Mythrandil](https://community.n8n.io/u/Mythrandil)\
**Post date:** [17 أكتوبر 2024، 9:29م UTC](https://community.n8n.io/t/n8n-postgres-via-cloudsql-auth-proxy-econnrefused/58326/1 "2024-10-17T21:29:18Z")

</div>

I’m trying to run N8N with a postgres DB hosted in GCP Cloud SQL. Doing so requires using [Cloud SQL Auth Proxy](https://cloud.google.com/sql/docs/postgres/sql-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)

```auto
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

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

```

Is there something missing?

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/26906_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [17 أكتوبر 2024، 9:29م UTC](https://community.n8n.io/t/n8n-postgres-via-cloudsql-auth-proxy-econnrefused/58326/2 "2024-10-17T21:29:19Z")

</div>

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:**

---

<div class="post-metadata">

**Author:** ![Mythrandil](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mythrandil/32/46691_2.png) [@Mythrandil](https://community.n8n.io/u/Mythrandil)\
**Post date:** [17 أكتوبر 2024، 9:32م UTC](https://community.n8n.io/t/n8n-postgres-via-cloudsql-auth-proxy-econnrefused/58326/3 "2024-10-17T21:32:01Z")

</div>

> [@n8n](#):
>
> - **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

---

<div class="post-metadata">

**Author:** ![barn4k](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/barn4k/32/8170_2.png) [@barn4k](https://community.n8n.io/u/barn4k)\
**Post date:** [18 أكتوبر 2024، 9:37ص UTC](https://community.n8n.io/t/n8n-postgres-via-cloudsql-auth-proxy-econnrefused/58326/4 "2024-10-18T09:37:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mythrandil](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mythrandil/32/46691_2.png) [@Mythrandil](https://community.n8n.io/u/Mythrandil)\
**Post date:** [18 أكتوبر 2024، 7:41م UTC](https://community.n8n.io/t/n8n-postgres-via-cloudsql-auth-proxy-econnrefused/58326/5 "2024-10-18T19:41:22Z")

</div>

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

```auto
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

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [16 يناير 2025، 7:42م UTC](https://community.n8n.io/t/n8n-postgres-via-cloudsql-auth-proxy-econnrefused/58326/6 "2025-01-16T19:42:06Z")

</div>

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