Apparent issue with postgres

  • **n8n version:1.72.1
  • **Database (default: SQLite):SQLite
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):N/A
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):Docker compose
  • **Operating system:Ubuntu 22.04

I’m somewhat new to n8n but I do have a few years’ experience of managing and maintaining docker containers on my home server.

I attempted to install n8n (docker-compose) a few days but kept getting errors that seemed to be postgres related.

Therefore, I completed an installation without the postgres and redis components (using the default SQLite database) and that seemed to work very well: I completed your level one course.

N-8-n is currently running on SQLite however, I understand that postgres is preferred (if at all possible) I’ve re-attempted to get postgres installed but this error keeps coming up:

PostgreSQL Database directory appears to contain a database; Skipping initialization
2024-12-25 16:07:46.455 UTC [1] LOG: starting PostgreSQL 16.6 (Debian 16.6-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2024-12-25 16:07:46.455 UTC [1] LOG: listening on IPv4 address “0.0.0.0”, port 5432
2024-12-25 16:07:46.455 UTC [1] LOG: listening on IPv6 address “::”, port 5432
2024-12-25 16:07:46.458 UTC [1] LOG: listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
2024-12-25 16:07:46.463 UTC [29] LOG: database system was shut down at 2024-12-25 16:07:45 UTC
2024-12-25 16:07:46.468 UTC [1] LOG: database system is ready to accept connections
2024-12-25 16:07:51.503 UTC [40] FATAL: role “postgres” does not exist
2024-12-25 16:07:56.583 UTC [48] FATAL: role “postgres” does not exist
2024-12-25 16:08:01.688 UTC [56] FATAL: role “postgres” does not exist

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I keep getting a 403 error (on this website) when attempting to post the relevant sections from my docker compose…I guess it’s because my account is new.

The relevant sections can be found below:
https://controlc.com/9fae1ca5

Welcome to the community @oneMore !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.

Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!


I wonder if what you expirience is addressed in https://medium.com/@chunkang.wong94/how-to-fix-the-role-postgres-does-not-exist-error-when-deploying-postgresql-docker-container-430e903b97fd.

Hello,
Thanks for the welcome and the response.

I did read that before and ran the commands advised but I don’t think that’s the solution for me.

Please see below:

onemore@uhts:~/docker$ sudo lsof -i :5433
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 2963707 root 4u IPv4 34733985 0t0 TCP *:5433 (LISTEN)
docker-pr 2963718 root 4u IPv6 34739861 0t0 TCP *:5433 (LISTEN)
onemore@uhts:~/docker$ sudo lsof -i :5432
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 638411 root 4u IPv4 26231160 0t0 TCP *:postgresql (LISTEN)
docker-pr 638420 root 4u IPv6 26232754 0t0 TCP *:postgresql (LISTEN)
onemore@uhts:~/docker$ sudo lsof -i :444
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 5164 root 4u IPv4 22883 0t0 TCP *:snpp (LISTEN)
docker-pr 5182 root 4u IPv6 20329 0t0 TCP *:snpp (LISTEN)

While this wasn’t exactly the solution, it got me thinking.

I’ve now managed to get it to behave.

Changes in bold below:

  #n8n Postgres - Postgres database for n8n
  n8n_postgres:
    image: postgres:16
    container_name: n8n_postgres
    hostname: n8n_postgres
    restart: always
    environment:
      - POSTGRES_USER=${N8N_POSTGRES_USER}
      - POSTGRES_PASSWORD=${N8N_POSTGRES_PASSWORD}
      - POSTGRES_DB=${N8N_POSTGRES_DB}
      - POSTGRES_NON_ROOT_USER=${N8N_POSTGRES_NON_ROOT_USER}
      - POSTGRES_NON_ROOT_PASSWORD=${N8N_POSTGRES_NON_ROOT_PASSWORD}
      **- PGPORT=5433**
    ports:
      - "**5433:5433**"
    volumes:
      - $DOCKERDIR/appdata/n8n_postgres/db_storage:/var/lib/postgresql/data
      - ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -h localhost -U ${N8N_POSTGRES_USER} -d ${N8N_POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 10
1 Like

Thanks for sharing. I have reformatted your post to make your updates better visible.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.