← All N8N workflows
Data & databasesCodeEmail SendError TriggerExecute WorkflowExecute Workflow Trigger

Log errors and avoid sending too many emails

Configured with Email Send, Error Trigger, Execute Workflow, Execute Workflow Trigger, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TriggerError TriggerError TriggerData storeInsert LogPostgresData storeCount for 5 minutesPostgresMessagingPrincipal E-MailEmail SendMessagingFallback E-MailEmail SendMessagingPush mobilenotificationPushoverData storeTruncate Log DatabasePostgresTriggerSometimes... justcleanupManual TriggerSubworkflowCall this Sample -Prepend to your error…Execute WorkflowTriggerSee below to prependthis at your error…Execute Workflow TriggerRoutingIf there is no logs in5 minutesIfCodeCleanUp execution. Seebelow if you will…CodeRoutingInsert your errorhandling logic after…No Op

Node categories in this workflow

  • Trigger
  • Data store
  • Messaging
  • Subworkflow
  • Routing
  • Code

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Error TriggerTriggerError TriggerSee node parameters
Insert LogData storePostgresSee node parameters
Count for 5 minutesData storePostgresexecuteQuery
Principal E-MailMessagingEmail SendSee node parameters
Fallback E-MailMessagingEmail SendSee node parameters
Push mobile notificationMessagingPushoverSee node parameters
Truncate Log DatabaseData storePostgresdeleteTable
Sometimes... just cleanupTriggerManual TriggerSee node parameters
Call this Sample - Prepend to your error catcherSubworkflowExecute WorkflowSee node parameters
See below to prepend this at your error handlingTriggerExecute Workflow TriggerSee node parameters
If there is no logs in 5 minutesRoutingIfSee node parameters
CleanUp execution. See below if you will prepend this workflowCodeCodeSee node parameters
Insert your error handling logic after thisRoutingNo OpSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • postgres
  • pushoverApi
  • smtp

Workflow notes

Log errors and avoid sending too many emails

Log errors and avoid sending too many emails

Use case

Most of the time, it’s necessary to log all errors that occur. However, in some cases, a scheduled task or service consuming excessive resources might trigger a surge of errors.

To address this, we can log all errors but limit alerts to a maximum of one notification every 5 minutes.

What this workflow does

This workflow can be configured to receive error events, or you can integrate it before your own error-handling logic.

If used as the primary error handler, note that this flow will only add a database log entry and take no further action. You’ll need to add your own alerts (e.g., email or push notifications). Below is an example of a notification setup I prefer to use.

At the end, there’s an error cleanup option. This feature is particularly useful in development environments.

If you already have an error-handling workflow, you can call this one as a sub-workflow. Its final steps include cleanup logic to reset the execution state and terminate the workflow.

Setup

Verify all Postgres nodes and credentials when using the 'Error Handling Sample'

How to adjust it to your needs

  1. You can set this workflow as a sub-workflow within your existing error-handling setup.

  2. Alternatively, you can add the "Error Handling Sample" at the end of this workflow, which sends email and push notifications.

Configuration Requirements:

⚠️ You must create a database table for this to work!

DDL of this sample:

create table p1gq6ljdsam3x1m."N8Err" ( id serial primary key, created_at timestamp, updated_at timestamp, created_by varchar, updated_by varchar, nc_order numeric, title text, "URL" text, "Stack" text, json json, "Message" text, "LastNode" text );

alter table p1gq6ljdsam3x1m."N8Err" owner to postgres;

create index "N8Err_order_idx" on p1gq6ljdsam3x1m."N8Err" (nc_order);

by Davi Saranszky Mesquita https://www.linkedin.com/in/mesquitadavi/

Log errors and avoid sending too many emails

Log errors and avoid sending too many emails

Purpose and structure

This folder contains the Log errors and avoid sending too many emails workflow. Its executable nodes use code, emailSend, errorTrigger, executeWorkflow, executeWorkflowTrigger, if, manualTrigger, noOp, postgres, pushover. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Error Trigger, Sometimes... just cleanup, See below to prepend this at your error handling

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Error/1777_Error_Postgres_Send_Triggered.json MIT; preserve source notices.

Canvas section labels

These name areas of the original canvas; they do not include explanatory instructions.

  • Error handling sample
  • Database Cleanup: Useful in DEV, but DO NOT run in production

More in Data & databases