N8n.service doesn't work, (code=exited, status=2)

I am having a problem with n8n on my server installed via npm

We can’t use docker, so we wanted to install it with npm and there is almost no documentation about it, everything is about docker.

The problem I have is that I created a n8n.service file, but it doesn’t work, this is the content of it:
[Unit]
Description=n8n
After=mariadb.service

[Service]
User=
Environment=NODE_PORT=5678
Environment=DB_TYPE=mariadb
Environment=DB_MYSQLDB_DATABASE=n8n
Environment=DB_MYSQLDB_HOST=127.0.0.1
Environment=DB_MYSQLDB_USER=
Environment=DB_MYSQLDB_PASSWORD=
Environment=GENERIC_TIMEZONE=Europe/Madrid
ExecStart=/var/www/n8n/node_modules/n8n/bin/n8n
WorkingDirectory=/var/www/n8n/
Restart=always

[Install]
WantedBy=multi-user.target

If I manually use the command
/var/www/n8n/node_modules/n8n/bin/n8n

It works, but with the service it gives error:


image

Information on your n8n setup

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

hello @SisNup

I think the issue with the DB. MariaDB is not officially supported.
And better to use docker as it greatly simplifies the setup and updating process

With Mariadb it works if I use the command:/var/www/n8n/node_modules/n8n/n8n/bin/n8n

It only fails in n8n.service

But i don’t know why

I’m afraid Docker is the only supported installation here on the forum.