How to install n8n on Portainer?

I hope this message finds you well. I am currently working on setting up an n8n instance, but I’ve encountered some issues related to database connectivity that I cannot seem to resolve. I would greatly appreciate any insights or recommendations from the community.

Current Setup:

  • n8n Version: latest
  • Database Options Tried: PostgreSQL and SQLite
  • Environment: OpenMediaVault with Portainer running, I run many other containers with no issue

PostgreSQL Configuration:

I initially set up PostgreSQL and configured n8n to connect to it with the following environment variables:
DB_TYPE: postgres
DB_POSTGRESDB: n8n
DB_POSTGRES_HOST: postgres # Service name in Docker Compose
DB_POSTGRES_PORT: 5432
DB_POSTGRES_USER: n8n
DB_POSTGRES_PASSWORD: n8n_password

While the PostgreSQL service starts up fine, I kept receiving errors related to connection failures in the n8n logs. Here are some of the relevant error messages I observed:
Error initializing DB: EACCES: permission denied, mkdir ‘/root/.n8n’

I also encountered several permission-related warnings about the settings file.

SQLite Configuration:

In an effort to troubleshoot, I tried switching to SQLite by modifying the n8n configuration:
DB_TYPE: sqlite
DB_SQLITE_DATABASE: /home/node/.n8n/database.sqlite

However, I continued to face issues where n8n failed to initialize, citing similar permission errors as when using PostgreSQL.

Troubleshooting Steps Taken:

  • Verified that both PostgreSQL and n8n are on the same Docker network.
  • Checked permissions on the volume directory mounted for n8n.
  • Set PUID and PGID to 0 in the environment to run as the root user.
  • Ensured appropriate permissions for the n8n directory on the host.
  • Verified that the databases are correctly created and accessible.

Questions:

  1. Are there specific logs or settings I should check for more detailed error messages?
  2. Has anyone else experienced similar database connection issues with n8n? What steps did you take to resolve them?
  3. Is there a preferred method for ensuring n8n can access its SQLite database without permission errors?

Any help or guidance would be immensely appreciated! Thank you for taking the time to read my post.

It really looks like a permission issue.

What sticks out to me is the mkdir /root/.n8n error. Looks like n8n is trying to write to the root user’s home directory.

Usually people running n8n run it with the node user that’s defined in the container image, which makes it possible to write to /home/node/.n8n

Here is an n8n docker-compose.yml with Postgres container included. It is from the official n8n project on github that has worked for me as it is:

there are also other useful compose files in this place

I agree it seems like permissions which is why I tried to run it last as the root user and even that didn’t help.
Running it with SQLLite everything should have been contained in the one compose but still the same issue.
On this compose file you sent. I am not sure where I put the .sh file since I am using the OMV OS. My Linux skills are not that great. Maybe I can copy it to one of my drive shares I am using for OMV and see if it will pick it up there. Thanks.

1 Like

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