Deplyinh N8N with amazon Postgresql RDS - Error on Last Session Crashed

I am trying to install n8n via docker-compose and use amazon RDS postgres as my database. The below is the docker-compose file

version: '3.8'

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=rds-n8n.xxxxx.rds.amazonaws.com
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=postgres
      - N8N_LOG_LEVEL=debug
      - DOMAIN_NAME=domain.net
      - SUBDOMAIN=soar
      - DB_POSTGRESDB_PASSWORD=xxxxxx
      - DATA_FOLDER=/home/ec2-user/n8n/data
      - NODE_ENV=production
      - DB_LOGGING_ENABLED=true
      - DB_LOGGING_OPTIONS=all
      - DEBUG=*
      - WEBHOOK_URL=http://soar.domain.net:5678/
      - GENERIC_TIMEZONE=Asia/Kolkata
    ports:
      - 5678:5678
    volumes:
      - /home/ec2-user/n8n/data:/home/ec2-user/.n8n

On doing, docker-compose up, I keep on getting error called Last session crashed "{ file: 'CrashJournal.js', function: 'init' }" without any explaination on what went wrong.

Logs for same

... trimmed ....
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:layer new '/:id(\\d+)'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:route get '/:id(\\d+)'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:layer new '/'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:route new '/:id(\\d+)'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:layer new '/:id(\\d+)'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:route patch '/:id(\\d+)'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:layer new '/'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:route new '/:id(\\d+)'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:layer new '/:id(\\d+)'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:route delete '/:id(\\d+)'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:router:layer new '/'
n8n-n8n-1  | 2023-07-31T08:25:33.948Z @oclif/config start prerun hook
n8n-n8n-1  | 2023-07-31T08:25:33.948Z @oclif/config prerun hook done
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "x-powered-by" to true
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "etag" to 'weak'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "etag fn" to [Function: generateETag]
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "env" to 'production'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "query parser" to 'extended'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "query parser fn" to [Function: parseExtendedQueryString]
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "subdomain offset" to 2
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "trust proxy" to false
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "trust proxy fn" to [Function: trustNone]
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application booting in production mode
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "view" to [Function: View]
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "views" to '/data/views'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "jsonp callback name" to 'callback'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "view cache" to true
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "x-powered-by" to false
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "view engine" to 'handlebars'
n8n-n8n-1  | Mon, 31 Jul 2023 08:25:33 GMT express:application set "views" to '/usr/local/lib/node_modules/n8n/templates'
n8n-n8n-1  | 2023-07-31T08:25:33.954Z | warn     | License manager not initialized "{ file: 'License.js', function: 'isFeatureEnabled' }"
n8n-n8n-1  | 2023-07-31T08:25:33.956Z | error    | Last session crashed "{ file: 'CrashJournal.js', function: 'init' }"

Would appreciate some help on this! Thanks

@seg_fault Can you please try setting N8N_DIAGNOSTICS_ENABLED to false ?
That should hopefully give you more info in the logs about why the crash is happening.

A better error now :-


n8n-n8n-1  | 2023-07-31T10:41:49.527Z | debug    | Lazy Loading credentials and nodes from n8n-nodes-base "{\n  credentials: 316,\n  nodes: 418,\n  file: 'DirectoryLoader.js',\n  function: 'loadAll'\n}"
n8n-n8n-1  | 2023-07-31T10:41:49.583Z | error    | Error: There was an error initializing DB "{ file: 'ErrorReporterProxy.js', function: 'report' }"
n8n-n8n-1  | 2023-07-31T10:41:49.584Z | error    | DatabaseError: no pg_hba.conf entry for host "172.24.9.51", user "postgres", database "n8n", no encryption "{ file: 'ErrorReporterProxy.js', function: 'report' }"

I believe there needs to be a host in pg_hba.conf but assuming i am running it in a docker container, do I add this by myself?

Have you checked if the user (with the correct password) and the database already exist on the RDS instance? n8n can’t create the database for you.
If you can access the database via another set of credentials, you’d need to run these

create database n8n;
create user n8n with encrypted password 'xxxxxx';
grant all privileges on database n8n to n8n;

and then update the env variables to match the correct credentials.

- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=xxxxxx

I have created the database n8n already and the current user postgres already has access to the newly created database.

in that case, you likely have force_ssl option enabled on your RDS instance.
You’d either need to disable that, or pass in the SSL certs to n8n, as described here,

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