N8n docker container crashes on startup (MariadDB connection)

Describe the problem/error/question

The n8n docker container crashes on startup. When removing the DB configurations from the docker-compose.yml, everything works fine.

What is the error message (if any)?

n8n | 2023-05-05T09:14:03.524Z | error | Last session crashed “{ file: ‘CrashJournal.js’, function: ‘init’ }”
n8n exited with code 0

crash.journal file & logs are empty

Please share your workflow

I have a server with a local MariaDB intallation. Then there’s docker running with traefik as reverse proxy & some other labeled containers that also connect to the local mariaDB instance. For some reason I can’t get my n8n container running when I configure the mariaDB connection. Removing the DB_… variables from the docker-compose file below starts the container without problems and is accessible through the configured URL

docker-compose.yml:

version: "3"

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    container_name: "n8n"
    restart: always
    command: n8n start --tunnel
    ports:
      - "127.0.0.1:5678:5678"
    networks:
      - traefik_default
    labels:
      - traefik.enable=true
      - "traefik.http.routers.n8n.rule=Host(`n8n.d17e.dev`)"
      - "traefik.http.routers.n8n.entrypoints=web, websecure"
      - "traefik.http.routers.n8n.tls=true"
      - "traefik.http.routers.n8n.tls.certresolver=production"
    environment:
      - N8N_LOG_LEVEL=verbose
      - N8N_LOG_OUTPUT=console,file
      - N8N_BASIC_AUTH_ACTIVE=false
      - N8N_HOST=n8n.d17e.dev
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://n8n.d17e.dev/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - DB_TYPE=mariadb
      - DB_MYSQLDB_HOST=${MARIADB_HOST}
      - DB_MYSQLDB_PORT=${MARIADB_PORT}
      - DB_MYSQLDB_DATABASE=${MARIADB_DATABASE}
      - DB_MYSQLDB_USER=${MARIADB_USER}
      - DB_MYSQLDB_PASSWORD=${MARIADB_PASSWORD}
    volumes:
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n
      - ${DATA_FOLDER}/n8n-local-files:/files

networks:
  traefik_default:
    external: true

the MARIADB_HOST is host.docker.internal as I’ve used for my other containers connecting to the same DB server. I’ve played around with the users but can’t seem to get anything to work. With the error message above the only output I get, so not sure what to do from here…

Information on your n8n setup

  • n8n version:0.224.4
  • Database (default: SQLite): MariaDB 10.6.11
  • n8n EXECUTIONS_PROCESS setting (default: own, main): ??
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker (see above)
  • Operating system: Ubuntu 22.04

Hi @d17e, I am sorry you’re having trouble. Are you also having trouble when using [email protected] containing a MariaDB-specific bug in a previous db migration? Is there any other console output apart from the line you have shared?

Hi @MutedJam, thanks for your reply!
Unfortunately I’m not getting any more logs. Even when I configure the verbose logging level I’m just getting the one line of output and an empty crashJournal file.
I’m currently on [email protected] and have reverted to using sqlite for now, but will do the upgrade and test if this resolves the issue. Keep you posted!

1 Like

Thanks for the heads-up!

Also, I just noticed a really dumb typo. [email protected] contains a MariaDB-specific fix rather than an additional bug :see_no_evil:

Hah, no worries about the typo… your message got through nonetheless :slight_smile:

Just pulled [email protected] (explicitly this version as the latest tag was still pointing to 0.225.x) and tried running but I’m getting the same result. No extra logs and exited with code 0… so no good news unfortunately.

Just so you know: when I run the same setup (n8n & traefik on docker + local MariaDB) on my local dev machine (win10) I’m not having any issues. I’m starting to think that it might be some access rights somewhere maybe as I’m not running docker/n8n as the root user? Either way that’s all just guesswork without any logs…
If there’s any way you can think of that I could collect some more logs somewhere, I’d be happy to try this out and provide the logs if so needed/wanted.

Hey @d17e,

If this is a new setup I would recommend using Postgres as we are planning to drop support for MySQL / MariaDB in a future release so it will save some time later.

I suspect the issue is probably with the mysql user or the host address but you could try setting DB_LOGGING_ENABLED to true and DB_LOGGING_OPTIONS to all

@Jon Thanks for the environment variables. Unfortunately that didn’t result in any extra logs so still stuck there…

As for the host address, I’m using ‘host.docker.internal’ that should get resolved to the actual host address. I’m using this host in other containers as well that connect to the DB without issues.
As for the DB user I created a user that has full access but only to the n8n DB. Tried running with the root user as well, but that gave the same behavior.

Also, good to know MySQL/MariaDB support will be dropped eventually. Thanks!

Hey @d17e,

As a test when using SQLite if you use the MySQL node with the same details does that show an error? I think the estimated time to drop support for MySQL is around 2 months.

1 Like

Hey @Jon

That was a great idea! I found out this way that the host.docker.internal did not actually get resolved to an actual IP. When replaced it by 172.22.0.1 everything is working fine. of course that’s not exactly desirable as the actual IP might get reassigned over time…

for reference I get following error message in the Mysql credential UI when using host.docker.internal:
getaddrinfo ENOTFOUND host.docker.internal

Thanks @Jon and @MutedJam for your time and input!

3 Likes

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