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.
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
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.