Postgres connection refused

Hello everyone,
I’m new to n8n and im trying to build a workflow within a sql query to an external postgres database.
When i try to create credentials with correct informations, i get an error “Connection refused” and i don’t understand why.
My n8n version is a self hosted docker container and database server is on the same local network. any help would be appreciated :slight_smile:

  • n8n version: Version 1.25.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Win server 2022

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:

Hey @mick,

Welcome to the community :raised_hands:

This is likely to be down to the Docker network settings or you are using the wrong host, Is your database also running in a container?

Hi @Jon thank you , no my database is on a dedicated server. Can you tell me setting i have to check ?

Hey @mick,

I think the first thing to check is that firewall is open on the postgres server to allow the connection, If that is all good it might be worth making sure your docker network is able to talk to other things a quick option for that might be to set it to bridge to see if that changes anything.

@Jon ,
there is no firewall and the connection is already set on bridge. When i do docker exec -it n8n sh then i ping my psql server there is a response

Hey @mick,

A ping is not really a good test for this as it doesn’t test the same protocol or port so all you really learn icmp traffic is allowed.

Does the postgres log show any attempt to access it? Connection refused is pretty standard so we know the connection is being refused on the other side we just need to work out why.

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