error fix

n8n Postgres Connection Error: Internal DB vs Postgres Node Fixes

A Postgres connection error in n8n can come from the self-hosted n8n database settings or from a workflow Postgres node credential; first separate infrastructure database errors from workflow node errors.

Independent third-party notes. n8n is a trademark of its owner and is referenced only for compatibility and troubleshooting context.

Quick Answer

A Postgres connection error in n8n can come from the self-hosted n8n database settings or from a workflow Postgres node credential; first separate infrastructure database errors from workflow node errors.

Problem Pattern

The user sees a Postgres connection failure but may be debugging the wrong layer: n8n's own database connection or a workflow Postgres node.

Key Facts

Two contexts
Postgres can be n8n's own database or a database accessed by a workflow node.
Self-hosted variable
n8n uses DB_TYPE=postgresdb and DB_POSTGRESDB_* variables for its own database.
Workflow node
The Postgres node uses its own database credentials.
Queue mode
Postgres is recommended for serious queue-mode deployments.

Recommended Steps

  1. Identify whether n8n itself fails to start or only a workflow Postgres node fails.
  2. For n8n's own database, check DB_TYPE and DB_POSTGRESDB_* variables.
  3. For a workflow node, test the Postgres credential and connection settings.
  4. Confirm host, port, database name, user, password, SSL, and schema.
  5. Check database network access from the n8n container or worker.

Verification

  • n8n starts without database connection errors.
  • The Postgres node can perform a low-risk SELECT query.
  • Queue workers can also reach the same database if queue mode is enabled.

Warnings

  • Do not expose Postgres publicly as a shortcut for container networking problems.
  • A workflow Postgres node credential is separate from the database n8n uses internally.

Common Mistakes

  • Using localhost inside a container when the database is another container or host.
  • Mixing up n8n internal database settings with Postgres node credentials.
  • Missing SSL settings required by a managed database provider.
  • Granting insufficient permissions for schema or trigger operations.

Examples

Context split Use this to avoid debugging the wrong layer.
n8n will not start: check DB_TYPE and DB_POSTGRESDB_* variables
Only one workflow fails: check Postgres node credentials
Queue workers fail: check worker environment and database network access

FAQ

Why does localhost fail from Docker?

Inside a container, localhost usually means the container itself. Use the correct Compose service name, host gateway, or network address for the database.

Do queue workers need the same database settings?

Yes. Workers need access to the same database and compatible environment configuration.

Sources