Local PostgreSQL - Connection Refused

Dear expert,

I used N8N Postgres Tool to create the credentials , connect to local PostgreSQL, and having Connection Refused.
The local PostgreSQL ( postgresql-17.4-1-windows-x64) working well with HeidiSQL.
Running n8n via Docker, Win 10 pro.

local PostgreSQL working well with HeidiSQL

Below is N8N Postgres Tool setting - Connection Refused

Information on your n8n setup

  • n8n version: 1.84.3
  • Database: postgresql-17.4-1-windows-x64 (insatll in PC)
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: win 10 pro

your n8n runs inside a docker container.
the database is not running inside this container, so it do not listen on 127.0.0.1:5432 in your container.
when your database is also running inside a docker and they are in the same docker network you can simply replace 127.0.0.1 with the name of your docker container.

If your service is running on your machine you can try using host.docker.internal

2 Likes

The self-hosted n8n installation runs inside a contianer, and so does the postgres instance - they need to use their internal* β€œLAN” to connect.

You can use this to get the IP for the credential:
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' self-hosted-ai-starter-kit-postgres-1

The internal IP is typically 172.18.0.2, but it may vary depending on if you already have other docker networks defined.

@Franz , I really appreciate it, you just brightened my day!

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