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
andPGID
to0
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:
- Are there specific logs or settings I should check for more detailed error messages?
- Has anyone else experienced similar database connection issues with n8n? What steps did you take to resolve them?
- 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.