Database event workflows with the n8n Postgres Trigger

A self-hosted n8n instance can start workflows from inserts, updates and deletes in PostgreSQL. This page explains how the trigger node manages database triggers, what permissions it needs, and when a custom NOTIFY channel is the safer choice.

On this page

How the n8n Postgres Trigger starts workflows from database changes

The n8n Postgres Trigger starts a workflow when a row is inserted, updated or deleted, or when a named channel receives a notification, so a team can react to a database change without polling the table. For a team that wants a database change to start a business process, this is the built-in method to evaluate first. The node works through a Postgres trigger that n8n manages for you: when a workflow is published, n8n creates the trigger on the target table, and when the workflow is unpublished, n8n removes it. That lifecycle matters for change control, because a published workflow changes the database schema of the table it watches, and an unpublished one should leave no trigger behind. Confirm with your own DBA which schema and table the trigger will touch, and whether your change process allows automatic DDL from an automation tool.

DeployOpen plans this work inside your own infrastructure, including the database account the node connects with, the tables and channels in scope, and how each published workflow is tested against a non-production copy before it reaches production. Ask for the exact database privileges the node needs in your environment and have them reviewed by the team that owns the database, since trigger creation is a privileged operation and should not be granted by default. Also plan for what happens when a workflow fails mid-run, and how you will confirm that no orphaned triggers remain after a workflow is deleted or a publish is rolled back.

n8n is source-available under the Sustainable Use License, not OSI open source, so review the license terms with your legal team before you embed this pattern in a product or distribute workflows outside your organization. PostgreSQL itself is released under the PostgreSQL License, a permissive open source license, which is a separate question from how n8n is licensed. Treat the two licenses as independent items in your review.

What you need before enabling Postgres triggers in n8n

The Postgres Trigger node depends on four things: a database version that is still supported, a role allowed to create and drop triggers, network paths from every n8n process that listens for events, and a secured connection. Confirm each with the database owner before you publish the first workflow, because the node changes the database when a workflow is published.

Supported PostgreSQL version

Check that your server runs a version still in its support window. Per the PostgreSQL versioning policy, versions 14 through 18 are currently supported, with 14 ending November 12, 2026, 15 ending November 11, 2027, 16 ending November 9, 2028, 17 ending November 8, 2029, and 18 ending November 14, 2030. Versions 13 and earlier are unsupported. Plan any upgrade before your version's end date, since trigger behavior should be tested on the version you will run in production.

Versioning policy

Database role and trigger privileges

The node creates a trigger on the target table when a workflow is published and removes it when the workflow is unpublished, so the connection role must be allowed to create and drop triggers on that table. Confirm with the database owner exactly which grants the role holds, and whether a separate role for n8n is preferred over a shared application account. Do not assume table ownership or superuser rights; ask for the minimum grants that cover trigger creation on the named tables.

Network reachability from n8n processes

In queue mode, the main instance handles triggers and webhooks, so the database must be reachable from the main instance. Confirm that firewall rules, security groups and any connection pooler such as PgBouncer allow connections from every n8n process that needs database access. Record the path from each host to the database port, because a trigger that works from one container may fail from another after a network change.

TLS and SCRAM authentication

Require encrypted connections between n8n and PostgreSQL, and confirm the server authenticates clients with SCRAM rather than MD5. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, so an older password setting may need a change on the server and in the connection role. Ask the database owner which authentication method and certificate validation mode apply, and whether the server certificate is trusted by the n8n host.

Authentication methods

n8n version and release notes

Confirm the n8n version you run against the current release notes before you rely on the Postgres Trigger behavior described here. n8n uses semantic versioning and ships minor releases roughly weekly, so node options and defaults can change between releases. Record the version in your change ticket, and retest trigger workflows after every n8n upgrade.

n8n release notes

How to configure the trigger, publish the workflow and verify events

This sequence takes a PostgreSQL table from no trigger to a published n8n workflow that runs once per table event, then back to a clean state. Each step ends with a check you can repeat in your own environment.

  1. Create a dedicated database role

    A database administrator creates a login role used only by n8n for this workflow, separate from the application account and any administrator account. Grant it connect access to the target database and the table privileges the workflow needs. Confirm the exact privileges that trigger creation requires in the Postgres Trigger node documentation before granting more. Check: connect as that role with psql and confirm it can read the target table and cannot alter unrelated schemas.

  2. Add the Postgres credential in n8n

    In n8n, create a Postgres credential that points to your database host, port and database name, using the role from the previous step. Store the password in your secret management process or environment rather than pasting it into a shared workflow. Check: the credential test reports a successful connection. If it fails, confirm the role's login and network access before changing any workflow settings.

  3. Select the target table and operations

    Add the Postgres Trigger node to a new workflow, choose the schema and table, and select insert, update, delete, or a named channel. Use a single test table for the first run so the execution log is easy to read. The named channel option fits when your application issues NOTIFY calls on purpose. Check: the node's preview or settings show the table and events you chose, and nothing else.

  4. Publish the workflow to create the trigger

    Publish the workflow. n8n creates a Postgres trigger on the target table as part of publishing. Query the catalog from psql to confirm it exists, replacing the example table name with yours: SELECT tgname, tgenabled FROM pg_trigger WHERE tgrelid = 'public.orders'::regclass AND NOT tgisinternal;. Record the trigger name so you can match it during removal. Check: the query returns one row for the trigger n8n created.

  5. Insert, update and delete test rows

    Run one insert, one update and one delete as separate statements against a test table or a non-production copy of the data, never live records. Keep each statement separate so each event is easy to match to an execution. Check: each statement produces a new entry in the n8n executions list, and the node output in the execution details identifies the row that changed.

  6. Confirm one execution per event

    Count the executions created by the three test statements. The count should match the number of events you expected. Then run a multi-row update and confirm whether the workflow executes once per affected row or once per statement, and record the answer for your design. Check: the execution count matches your documented expectations for both the single-row and multi-row tests.

  7. Unpublish and confirm trigger removal

    Unpublish the workflow. n8n removes the trigger it created when the workflow is unpublished. Rerun the catalog query from the publish step. Then run one more insert and confirm no new execution appears in n8n. Check: the catalog query returns no row for the trigger, and the insert produces no execution, which shows the table is back to its prior state.

What happens to the database when a workflow is published

When you publish a workflow that uses the Postgres Trigger node, n8n creates a Postgres trigger on the target table, and when you unpublish it, n8n removes that trigger. The database object is created by the n8n service account at runtime, not by your migration scripts or schema repository. That means the table gains a trigger that no one on the database team may have reviewed, and the trigger's lifecycle follows the workflow's publish state rather than a deployment pipeline. Before go-live, ask the DBA team to confirm which role n8n connects with, what privileges that role holds on the target schema, and whether the organization's policy allows application services to create triggers at all. Confirm these behaviors on the n8n version you run, since the trigger creation logic belongs to the node and can change between releases. The Postgres Trigger node documentation is the place to start.

Schema changes deserve a specific check. A migration that renames or drops the watched table, or changes the columns the workflow depends on, can break the trigger or leave the workflow listening to an object that no longer matches its expectations. Drop operations can also fail if a trigger still exists, so teams should plan the order of steps: unpublish the workflow, run the migration, then republish and verify. Add a runbook step that lists every published Postgres Trigger workflow against each table in the migration, and make the migration owner responsible for that list. If several workflows watch the same table, each one carries its own trigger, so a single unpublish affects only its own workflow and a schema change affects all of them at once. Record which workflows share a table so a reviewer can see the full impact before approving a change.

A change-management owner should treat these triggers as database objects with an owner, a review path and an inventory. Triggers created outside the schema repository do not appear in migration diffs, so a periodic query of trigger definitions on the watched tables is a practical control to add to your monitoring. Ask for a written list of tables touched by n8n, the workflows responsible for each, and the person accountable for approving changes. For an illustrative case, a team that renames a column in a monitored table without knowing a workflow is subscribed would discover the failure only when downstream records stop updating. Clear ownership and a standing inventory prevent that surprise and give auditors a traceable record of who authorized each database change.

Native table triggers or a custom NOTIFY channel

The Postgres Trigger node listens for insert, update and delete events on a table you select. When the workflow is published, n8n creates a Postgres trigger on that table, and when the workflow is unpublished, n8n removes it. The database side is therefore generated by n8n rather than written by your team, which shortens the build for a single table with a clear change pattern.

  • Low build effort: Teams configure the table and event type in the node instead of writing trigger functions and channel listeners.
  • Lifecycle tied to the workflow: Triggers appear and disappear with publish and unpublish, so cleanup does not depend on a separate change ticket.
  • Coupling to the table: Changes to table names, schemas or permissions can break the trigger, so the workflow owner must track schema changes.
  • Harder to review: The generated trigger definition is created by n8n, so the database team must inspect it in each environment before approving it.
  • Permission scope: The database role used by n8n needs rights to create and drop triggers, which the database team will want to scope and document.

Confirm with the database team which role n8n will use, which tables are in scope, and whether they accept n8n-managed triggers in production.

Mapping database events to workflow fields and operations

This table compares what each Postgres Trigger event gives the workflow, which fields identify the changed row, and what your team must define before building. Check every row against the node output from a test table, since payload shape is the detail most likely to differ from what you assume. The main takeaway is that every operation depends on a stable primary key, and deletes and named channels need extra design work.

OperationWhat the workflow receivesDefine in the design or confirm in test
InsertColumns of the new row as the trigger passes them to n8nConfirm the primary key and all needed columns appear in the payload
UpdateColumns of the row after the change, identified the same way as insertsConfirm whether prior values are included before relying on them for change detection
DeleteData for a row that no longer exists in the tableDesign steps to use the payload only, since a follow-up query for the row will find nothing
Named channelThe text payload your database sends with NOTIFY, parsed in a workflow stepAgree the channel name, a JSON schema and an id field with the team that publishes events
Primary keyUsed to link insert, update and delete events for the same recordChoose a single stable key per table; composite or missing keys make matching harder
updated_at columnNot created by the trigger; the workflow reads it only if the table has itDecide who sets it, how it is backfilled, and whether a version column is needed for repeat events
Repeated or retried eventsDuplicate events may arrive for one change, depending on how the database and node behaveConfirm in test, then make downstream writes idempotent by keying them on the primary key

How a row change reaches an n8n execution

A change starts when an application writes a row to a PostgreSQL table. The trigger that n8n created on that table fires and sends the event to the n8n main instance, which owns triggers and decides when a workflow runs. In queue mode, the execution passes through Redis to a worker, and the worker reads the stored credentials using the encryption key shared across n8n processes. Check each boundary: the database role, the network path to the main instance, and the credentials each downstream system receives.

Path of a database event from the application to a downstream system, with trust boundaries marked.

Securing the database role, credentials and triggered workflows

A Postgres Trigger workflow touches three things: the database role n8n connects with, the credential that role's password lives in, and the workflows that can create database objects on your behalf. Each card below covers one of these controls, so the database team and the n8n administrators can agree on who owns which part before the first workflow is published.

Scope the database role

Create a dedicated PostgreSQL login for n8n instead of reusing an owner or administrator account. Grant only the tables, columns and operations the workflows read, and confirm whether the role also needs rights to create triggers and functions on those tables, since the Postgres Trigger node creates them when a workflow is published. Review that grant list whenever a new trigger workflow is proposed. Ask the DBA to document the grant set in writing.

Postgres Trigger docs

Use SCRAM password authentication

Set the role's password under SCRAM rather than MD5, and confirm the server's password encryption setting and the pg_hba.conf rule that n8n's connection matches. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, so a database that still accepts MD5 for this role should be fixed before go-live. Check the authentication method against the PostgreSQL client authentication options your security team has approved.

Authentication methods

Encrypt the connection with TLS

Require TLS between the n8n main instance, every worker and the database, so database credentials and row data are not sent in clear text across the network. Decide which certificate authority the n8n containers trust and how certificate rotation reaches each process. Test the connection with the exact SSL settings you plan to use in production, because a setting that works from an administrator workstation may not work from a worker subnet.

Store the credential with the encryption key

n8n encrypts stored credentials with its encryption key, and in queue mode the same key must be shared with every worker and webhook processor so they can read the Postgres credential from the database. Keep that key in your secrets manager, restrict who can read it, and record where each copy is deployed. Losing or changing the key makes stored credentials unusable, so include it in backup and recovery planning.

Queue mode docs

Restrict who can publish database triggers

Publishing a Postgres Trigger workflow creates a trigger on the target table, and unpublishing removes it, so publish rights are effectively rights to change the schema. Limit publishing on the production instance to a small group, route trigger workflows through review in a lower environment first, and check whether your plan's role and project controls can enforce that separation. Confirm this with n8n's current SSO and access documentation for your edition.

Audit trigger creation and removal

Record each time a trigger is created or dropped, who published or unpublished the workflow, and which table was affected. Compare the trigger list in pg_trigger against the published workflows on a schedule so an orphaned trigger left by a failed unpublish is found quickly. Confirm which n8n audit and log features your edition provides, and keep database logs for the statements that modify triggers.

Why the trigger does not fire or leaves objects behind

This table lists the failures most often seen when the Postgres Trigger node is used, with the cause and fix for each. Read it when a workflow is published but silent, when a table change breaks a workflow, or when database objects remain after an unpublish.

FailureCauseFix
Trigger cannot be createdThe database role used by the credential lacks the privileges needed to create a trigger and function on the target tableGrant the role trigger privileges on the table through a dedicated account, then republish the workflow and confirm the trigger exists
Workflow stays published after a table renameThe trigger is attached to the table by name, so renaming or dropping the table leaves the workflow listening to a table that no longer matchesUnpublish the workflow before schema changes, apply the rename, then update the table name in the node and publish again
Events missing in queue modeThe worker or webhook processor does not have the encryption key or database access it needs to load the credential, so trigger executions failShare the main instance encryption key with all workers and confirm each worker reaches the same PostgreSQL database and shows the expected credentials
Duplicate executions on one tableSeveral workflows publish their own trigger on the same table, so each database change starts one run per workflowKeep one workflow per table where possible, route the event from that workflow to the others, or filter events by operation and channel
Connection drops through PgBouncer or after failoverThe trigger listener holds a long-lived session that a pooler or a failover severs, and the node may not reattach to the new primaryPoint the trigger credential at a direct primary connection rather than a transaction-pooled path, then check that the node reconnects after a planned failover test
Trigger left behind after failed unpublishUnpublishing failed partway, for example because of a lost connection or insufficient privileges, so the database object was not removedFind the leftover trigger and function in the database, remove them with the account that owns them, and confirm no workflow still expects them
Custom NOTIFY channel not receiving messagesThe sending side uses a different channel name, the payload is not sent, or the listener is not connected to the same databaseCompare the channel name in the NOTIFY statement with the node setting, then send a test notification from a SQL session on the same database

Questions buyers ask about Postgres triggers in n8n

Can our team set up n8n Postgres triggers ourselves?

Yes, a team with n8n and PostgreSQL experience can usually set up a single workflow on a single table without a partner. The node creates a Postgres trigger on the target table when the workflow is published and removes it when the workflow is unpublished, so the basic path is short. The harder part is everything around it: who approves database changes, how the trigger is tested under real write load, what happens when the n8n instance is down during a burst of changes, and how the setup is documented for the next person. If your team already owns those practices, an in-house build is reasonable. If not, the gaps are usually in operations rather than in the node settings.

What drives the effort of a database event workflow project?

The main drivers are the number of tables, the event volume on each one, and whether you use the node's native insert, update and delete events or a custom NOTIFY channel. Each watched table gets its own trigger, so a dozen tables means a dozen objects to review, name, monitor and remove later. High write volume raises the importance of filtering, batching and testing the cost of each event. Designing a NOTIFY channel adds payload design and listener logic, but it lets you decouple event naming from table names. Queue mode and high availability add further work, because the encryption key must be shared with every worker and webhook processor, and multi-main setup is restricted to Enterprise self-hosted deployments according to n8n's queue mode documentation. Confirm each of these with your own environment before estimating.

What does the work need from our DBA and our n8n owner?

The DBA decides which role the n8n connection uses, reviews the privileges that creating and dropping triggers requires, and confirms how trigger changes fit into schema change control. The n8n owner decides which workflows are published, how credentials are stored and shared across processes, and how executions are monitored. Both should agree on the list of watched tables, the naming convention for channels and the process for unpublishing a workflow before a schema migration. Ask the DBA to check the connection's permissions against the Postgres Trigger node documentation before any production change, because trigger creation is a privileged action in PostgreSQL. Expect a short working session at the start and another at go-live.

Does our n8n plan matter for the Postgres Trigger node?

The node itself is part of the workflow feature set, and n8n states that all plans include unlimited users, workflows and every integration. Features such as SSO and LDAP, environments with Git and log streaming are included only in the Business and Enterprise plans, according to n8n's pricing page. Those features matter if your database event workflows need controlled promotion between environments or centralized sign-in for the people who maintain them. Check the current pricing page before you commit, because plan contents and the Business plan's self-hosted-only availability can change. Ask n8n or your reseller to confirm in writing which plan covers each feature you need.

How does the Postgres Trigger node behave during a PostgreSQL upgrade?

Triggers are database objects, so they are part of the schema that a major upgrade must carry across. PostgreSQL offers dump and restore, pg_upgrade and logical replication for major upgrades, and logical replication allows upgrades with only several seconds of downtime according to the PostgreSQL upgrading documentation. Before any major upgrade, confirm that the n8n trigger objects are included in the migration and that the workflows still publish and listen after the cutover. Minor releases do not change the storage format, so updating them is usually a matter of replacing executables and restarting. Plan the PostgreSQL version against the support dates, since version 14 is supported to November 12, 2026 and version 18 to November 14, 2030, per the PostgreSQL versioning policy.

What is included in a fixed-scope DeployOpen engagement for this?

Most DeployOpen engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. For this topic, a written scope would normally name the tables and events in scope, the choice between native trigger events and a custom NOTIFY channel, the connection and privilege model, the queue mode and high availability assumptions, and the testing and handover materials. DeployOpen does not publish a price list, so the quote follows from that written scope. Ask for the scope to list what is excluded, such as application changes, database schema changes and any upgrade work, so that you can compare proposals on the same basis. Ongoing support and upgrades are available as retainers.

Is a custom NOTIFY channel safer than the built-in trigger?

Neither option is inherently safer, and the right choice depends on what you need to observe and who controls the database. The built-in trigger events for insert, update and delete are simple to explain and create a trigger on the target table when the workflow is published. A named NOTIFY channel lets your application or database functions publish deliberate events, which is useful when a business event spans several tables or should not expose internal column changes. The trade-off is that your team owns the payload design and the listener's behavior. Confirm with your security team how the connection's privileges, payload contents and logging will be reviewed before choosing.

How DeployOpen scopes and delivers this integration

DeployOpen starts by mapping the database events your workflows must react to. That means listing the tables, the operations (insert, update, delete) and any custom NOTIFY channels, then confirming which PostgreSQL instance and database role each workflow will use. Because the Postgres Trigger node creates and removes database triggers on the target table as workflows are published and unpublished, the scope also has to say who approves that DDL activity on production tables. We agree this inventory, the n8n edition and the hosting boundary in writing before any build work begins, so the database team knows exactly which objects will change and when.

The build happens inside your infrastructure, in your cloud accounts, data centers or restricted network. DeployOpen configures the database role with the minimum privileges the trigger node needs, sets up the n8n instance and its credentials, and, where a NOTIFY channel is used instead, writes the trigger function and listener workflow so the database team can review the SQL before it reaches production. Testing runs against a staging copy of your schema with your database team present. The team checks that events fire once, that unpublishing a workflow removes its trigger, and that high write volumes on the target table do not slow application transactions. Confirm with your database owners which PostgreSQL major version you run and how it is patched, since that affects both the trigger behavior and the upgrade plan.

Most engagements are fixed-scope, and the quote follows from the written scope, so ask for the cost of the event inventory, the database role design, the test cycle and the handover separately. Retainers cover the recurring work: applying n8n upgrades, re-testing triggers after PostgreSQL minor or major upgrades, and reviewing new database-triggered workflows as they are added. Ask any provider how they will handle n8n license terms for your use case and who keeps the runbook current after handover.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.