Unable to connect Postgres DB with n8n

HI guys, I have self hosted n8n on my remote server and running it via docker compose. I am trying to connect my postgres db running on same server . I have allowed remote connections with the postgres and provided the ssh credentials for connections.
Am getting an error:
listen EADDRINUSE: address already in use 127.0.0.1:5432
How do make the connection successful

Information on your n8n setup

  • **n8n version:1.17.1
  • **Database :postgres
  • n8n EXECUTIONS_PROCESS setting (own):
  • Running n8n via (Docker compose):
  • **Operating system:linux

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 @Rajan,

That error is saying that port 5432 is already being used in your n8n container, I suspect that means a previous connection has not disconnected properly so if you were to change that to something else it should work. I would also recommend upgrading as I know we fixed some issues with postgres and ssh tunnels although if everything is on the same machine you shouldn’t need a tunnel and you will be able to connect through the docker networking.

@Jon @Rajan I am having same issue with Postgres node. I have latest n8n and trying to connect through ssh tunnelling. Just to make sure that connection working, I was able to connect to this server and db from pgadmin on a different machine and that worked. Hope it gives some help with getting to the bottom.

Hey @alexh2,

Welcome to the community :cake:

Can you share n8n version you are using and the error message you are getting?

It just says there is already process on 127.0.0.1:5432. Not sure why It’s as if it is confusing as if it is trying to get to it’s own instance which is local at 5432?

Have you tried changing the port? If you are running Postgres on the same box and trying to use a tunnel the tunnel connection will try and use the same port which will cause an error.

Thanks for the reply Jon. Below is screenshot of my config.

SSH tunnel is used which means it is different server. And port in n8n server is 5222 which is different from 5432 that n8n uses.

Also noticed sometimes when you press “Save” it keep stuck at “Saving” but when I check inspect don’t seem process does complete in websocket.


Hey @alexh2,

Can you try updating your n8n instance? I have just tested on 1.30.1 and it is working as expected so I wonder if this is an old bug that we fixed. I remember fixing some issues with the tunnels a while back.

Ok I will try that and also make fresh work flow to see if that does the trick.

Thanks!

1 Like

latest in docker is 1.29.1 @Jon ?

The latest tag will be 1.29.1 but the latest actual version is 1.30.1

yep, tried that. Same issue.

I will move on for now. May be it’s just me. Thanks

1 Like