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
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.
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.
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.
I noticed that it only occurs when using ssh tunnel connections
In my case I managed to overcome the problem by configuring the “SSH Postgres Port” property
to a different port for each of my postgres credentials
the problem continues to occur but less often
As I use the same credential in more than one flow, n8n may still try to create the tunnel twice with the same credential
I also configured the nodes to try again in case of an error
but I think a definitive solution would be for n8n itself to check and reuse the tunnel that is already open for the connection, or something like that