How to Connect PostgreSQL to n8n, Integrate Postgres Easily 2026
By Impran M N
If you want your n8n automations to read from or write to a relational database, PostgreSQL is one of the most common choices, and n8n has a dedicated node for it. This guide walks through adding the Postgres node to your canvas, securing your connection credentials, and choosing between visual data operations and raw SQL. By the end you'll be able to insert, update, and query rows as part of a live workflow.
01Open a workflow canvas
Start from your n8n dashboard and create a new, empty workflow so you have a clean space to build the database integration.
02Add the PostgreSQL node
Search for and drop the official PostgreSQL node onto the canvas from the node panel.
03Configure your credentials
Open the credentials section and enter your Postgres host, database name, port, and authentication details. Keep these values in a credential profile rather than hardcoding them in the workflow.
04Choose an operation
Decide whether to use the visual builder for inserting, updating, or selecting rows, or switch to the custom SQL editor for more complex multi-table queries.
05Map your data and connect the node
Define the target table and map incoming JSON fields to the right columns, then connect the node into the rest of your workflow sequence.
06Test the connection
Run the node manually to confirm the query executes and the returned data looks correct before relying on it in production.
Frequently asked questions
Do I need a separate database server to use this node?
Yes, the PostgreSQL node connects to an existing Postgres instance, whether that's self-hosted, on a VPS, or a managed cloud database — n8n doesn't include a database itself.
Can I write raw SQL instead of using the visual builder?
Yes, the node supports a custom SQL query mode for cases like multi-table joins or bulk updates that the visual operation builder can't express.
Is it safe to store my database password in n8n?
Store it as a credential rather than typing it into node parameters directly, and treat those credential values the same way you'd treat any production database password.
Why is my node returning a connection error?
Double-check the host, port, database name, and firewall or network access rules — a common cause is the database not accepting external connections from n8n's host.
Watch the full walkthrough
The same steps, demonstrated on screen from start to finish.



