Issue connecting n8n to Postgres Credentials via 127.0.0.1 or localhost: Authentication Failed

I am facing an issue when trying to connect n8n to my local PostgreSQL database. The configuration seems correct, and the same credentials work perfectly with pgAdmin 4 and psql in the terminal, but n8n fails to authenticate when trying to connect. I’m running PostgreSQL via pgAdmin 4 on macOS and n8n self host is running in Docker.

No specific error message appears in the n8n UI, but based on the logs, the connection to PostgreSQL is not authenticated correctly.

Here is my configuration in n8n for Postgres


  • Host: 127.0.0.1

  • Port: 5434

  • Database: inwout-laboral

  • User: albertpuey

  • Password: postgres1234 (it works in pgAdmin and psql)

  • n8n version: 1.59.3

  • Database): Using PostgreSQL for external database

  • n8n EXECUTIONS_PROCESS: own

  • Running n8n via: Docker

  • Operating system: macOS Sonora 14.6.1

Additionally, here’s a screenshot of my pgAdmin session, showing that I can connect to the database with no issues:

I have modified the pg_hba.conf to use md5 for password authentication and restarted PostgreSQL.
I have tried using localhost and 127.0.0.1 as the host, but neither resolves the issue in n8n.
The Docker logs do not provide a clear error related to PostgreSQL.
Thanks for any type of help!

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:

Welcome to the community @Albert_Blanco !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.


Try host.docker.internal instead of localhost. The problem is, you are trying to connect to the host from the container. Addressing the host via 127.0.0.1 will not work.

i’ve tested the local host port on my terminal and pgadmin and it provides me with data but when i try connect it to n8n it just doesn’t seem to go through i’ve read the documentation as well and i checked my postgres server to make sure it is on a localhost as well

need help on my file as well as i am having similar issues i am using a localhost and i get the error connection refused. i’ve tried every thing i’ve got on me even modifying the config to accept all entries from different host

Couldn’t connect with these settings

Retry

Connection refused

Host
localhost
Database
n8n
User
postgres
Password
••••••••••••••••••••••••••••••••••••••••••••••••••••••
Ignore SSL Issues

SSL
Disable
Port
5432
SSH Tunnel