// guides · n8n error index

n8n Postgres node errors: connection, SQL and insert fixes, 33 runs

Fix n8n Postgres node errors: Connection refused, password authentication failed, self-signed certificate, relation or column does not exist, duplicate key, ON CONFLICT and $1 parameter errors. From 33 real runs on n8n 2.43.7 and PostgreSQL 17.

Updated 2026-10-23 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. Read the connection error first

    If the node fails before any SQL runs, the credential is the problem, not your query. In our runs a closed port gave Connection refused with 127.0.0.1:5432 under it. A wrong password gave password authentication failed for user "app", and so did a user that doesn't exist at all (password authentication failed for user "n8n"), so check the user name too. A typo in the database name gave database "shopp" does not exist. If n8n runs in Docker, localhost is the n8n container itself: use the Postgres service name or the host's address as Host. If it's n8n's own database that refuses to connect at startup, see n8n won't start: self-hosting errors instead.

  2. Match the SSL setting to the server

    With SSL set to Require and a server using a self-signed certificate, the node failed with self-signed certificate; if the root CA is installed locally, try running Node.js with --use-system-ca. Turning on Ignore SSL Issues (Insecure) in the same credential connected, and pg_stat_ssl confirmed the session was encrypted. The other way round, a server that only accepts SSL (a hostssl line in pg_hba.conf, as many hosted databases do) rejected SSL Disable with no pg_hba.conf entry for host "127.0.0.1", user "app", database "shop", no encryption. Set SSL to Require for hosted Postgres.

  3. Quote mixed-case table and column names

    Postgres folds unquoted names to lower case. In Execute Query, select * from Customers failed with relation "customers" does not exist and select firstName from "Customers" failed with column "firstname" does not exist, with the hint Perhaps you meant to reference the column "Customers.firstName". Write "Customers" and "firstName" with double quotes. The node's own Select, Insert and Upsert operations quote names for you: Select on the table Customers worked without any change.

  4. Handle duplicates with Upsert or Skip on Conflict

    Inserting an email that already existed failed with duplicate key value violates unique constraint "users_email_key" and the detail Key (email)=(a@x.io) already exists., both in Execute Query and in the Insert operation. Two fixes worked: the Insert option Skip on Conflict (output {"success": true}, row left untouched), or the Insert or Update (upsert) operation matching on email, which updated the row. Upsert only works on a column with a unique index or primary key: matching on name failed with there is no unique or exclusion constraint matching the ON CONFLICT specification. With several items, the default batching (Single Query) and Transaction inserted nothing when one item was a duplicate; Independently inserted the rows before it; Independently plus On Error: Continue inserted all the others.

  5. Pass values as $1 parameters, the right way

    Putting {{ $json.name }} straight into SQL broke on a name with an apostrophe: Syntax error at line 1 near "Brien". Use $1 in the query and the value in Options → Query Parameters: the same O'Brien value then ran without error. Without Query Parameters, $1 gives there is no parameter $1. Watch out for commas: Query Parameters splits a string on commas, so {{ 'Smith, John' }} arrived as Smith with no error at all. Wrap the value in an array, {{ [$json.name] }}, and the full Smith, John came through. A text value sent to an integer column, by parameter or by Insert, failed with invalid input syntax for type integer: "abc".

What we ran

On 23 October 2026 we ran n8n 2.43.7 (npm install, Node 24) against a local PostgreSQL 17.11 server with a self-signed certificate, using the Postgres node version 2.6. Each case was a small workflow run with n8n execute: a Manual Trigger, sometimes a first Postgres node that produced the input items, then the Postgres node under test. One credential per connection case. 33 runs in total; every message below is copied from the execution data.

SetupResult
Correct host, port, database, user, password (SSL Disable)Success: current_user app, ssl false
Port 5432, nothing listeningConnection refused, details 127.0.0.1:5432 (log: connect ECONNREFUSED 127.0.0.1:5432)
Host that doesn't answer, no Connection Timeout setHung for over 2 minutes, then Connection timed out (connect ETIMEDOUT)
Same unreachable host, Options → Connection Timeout 5Failed after about 5 s: Connection terminated due to connection timeout
Wrong passwordpassword authentication failed for user "app"
User that doesn't existpassword authentication failed for user "n8n" (same message as a wrong password)
Database name typodatabase "shopp" does not exist
SSL Require, server certificate self-signedself-signed certificate; if the root CA is installed locally, try running Node.js with --use-system-ca
SSL Require + Ignore SSL IssuesSuccess, ssl true
Server accepts SSL only (hostssl), credential SSL Disableno pg_hba.conf entry for host "127.0.0.1", user "app", database "shop", no encryption
Server accepts SSL only, SSL Require + Ignore SSL IssuesSuccess, ssl true
Execute Query select * from Customers (table created as "Customers")relation "customers" does not exist
Execute Query with "Customers" in double quotesSuccess, 1 row
Execute Query select firstName from "Customers"column "firstname" does not exist, hint Perhaps you meant to reference the column "Customers.firstName".
Select operation, table Customers picked by nameSuccess, 1 row (the node quotes names)
Execute Query insert of an email that existsduplicate key value violates unique constraint "users_email_key", Key (email)=(a@x.io) already exists.
Insert operation, same duplicateSame duplicate key error
Insert operation + Skip on ConflictSuccess, output {"success": true}, existing row unchanged
Insert or Update (upsert), match on email (unique)Success, existing row updated (name and age)
Insert or Update, match on name (no unique index)there is no unique or exclusion constraint matching the ON CONFLICT specification
Insert, input item has a field the table lacks (phone)Column 'phone' does not exist in selected table (n8n's own check, before any SQL)
Insert, age = "abc" into an integer columninvalid input syntax for type integer: "abc"
where id = $1, Query Parameters abcinvalid input syntax for type integer: "abc"
where id = $1, no Query Parametersthere is no parameter $1
select $1::text, Query Parameters {{ 'Smith, John' }}No error, but the value was cut to Smith
Same, Query Parameters {{ ['Smith, John'] }}Success, Smith, John
Name O'Brien put in the SQL with '{{ $json.name }}'Syntax error at line 1 near "Brien"
Name O'Brien passed as $1 in Query ParametersSuccess (no error, 0 rows)
Role with statement_timeout 2s, select pg_sleep(5)canceling statement due to statement timeout
3 items, 2nd a duplicate, Query Batching: Single Query (default)Duplicate key error, none of the 3 inserted
Same, Query Batching: IndependentlyDuplicate key error, 1st row inserted, 3rd not
Same, Query Batching: TransactionDuplicate key error, none inserted
Same, Independently + On Error: Continue (regular output)1st and 3rd inserted; the duplicate came out as an item with an error field

Good to know

What we didn't test

FAQ

Why does the n8n Postgres node say Connection refused?

Nothing is listening on that host and port, as n8n sees it. In Docker, localhost is the n8n container, so use the Postgres service name or the host's address, and check the port (5432 by default) and that Postgres listens on that interface.

Why do I get password authentication failed in n8n when the password is right?

Postgres gives the same message for a user that doesn't exist. In our test a wrong user name and a wrong password both returned password authentication failed for user, so check the User field and that the user has a password set.

How do I fix self-signed certificate in the n8n Postgres credential?

Keep SSL on Require and turn on Ignore SSL Issues (Insecure) in the credential. In our test that connected with an encrypted session. If the server only accepts SSL, SSL Disable fails with no pg_hba.conf entry ... no encryption.

Why does n8n say relation does not exist when the table exists?

The table name has capital letters. Postgres lowers unquoted names, so select * from Customers looks for customers. Use double quotes in Execute Query ("Customers"), or use the node's Select, Insert or Upsert operations, which quote names for you.

How do I use $1 query parameters in the n8n Postgres node?

Write $1, $2 in the query and put the values in Options, Query Parameters. A plain string is split on commas, so a value like Smith, John becomes Smith; pass an array instead, for example {{ [$json.name] }}. Without Query Parameters you get there is no parameter $1.

Related guides

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.