Having trouble connecting to postgres db on another container

Describe the problem/error/question

I want to use postgres to stock some data during workflows. I set up the postgres container and I can reach it using postbird form my machine.
When I set up the credentials in N8N, it doesn’t work. It tries to test the connection without succeeding.

I used the same credentials I used with postbird.
As host I used the public ip of my VPS, although the containers are in the same network. I also tried using the ip of the network, without success.

Information on your n8n setup

  • n8n version: 1.81.4
  • Database (default: SQLite): SQLite
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker compose

Have you try to connect it out of n8n, like terminal or python?

Yes, and it works without any problem.

I got it work!
The problem was the host: I needed to use the container name. Not the public IP, not the local ip, precisely the container name.

Well, now it’s working and I learned something. Hope that helps somebody else in the future.

1 Like

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