I’m trying to install n8n on my DS218 with docker, with the existing docker-compose file from GitHub. I can get both docker container installed without errors, but after then the n8n container keeps restarting all the time. Here are my modified docker-compose and the error log:
Docker Compose
version: '3.1'
services:
postgres:
image: postgres:11
restart: always
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
- POSTGRES_NON_ROOT_USER
- POSTGRES_NON_ROOT_PASSWORD
volumes:
- ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
n8n:
image: n8nio/n8n
restart: always
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
- DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
- DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER
- N8N_BASIC_AUTH_PASSWORD
ports:
- 5678:5678
links:
- postgres
volumes:
- /volume1/docker/n8n:/home/node/.n8n
# Wait 5 seconds to start n8n to make sure that PostgreSQL is ready
# when n8n tries to connect to it
command: /bin/sh -c "sleep 5; n8n start"
Error Log
|date|stream|content|
|---|---|---|
|2021-03-22 09:45:35|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:45:35|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:44:58|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:44:58|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:44:35|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:44:35|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:44:18|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:44:18|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:44:04|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:44:04|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:43:52|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:43:52|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:43:40|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:43:40|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:43:29|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:43:29|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:43:17|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 09:43:17|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 09:43:03|stdout|Stopping n8n...|
|2021-03-22 09:43:03|stdout||
|2021-03-22 09:43:03|stderr|There was an error initializing DB: connect ECONNREFUSED 172.18.0.3:5432|
|2021-03-22 09:43:03|stdout|UserSettings got generated and saved to: /home/node/.n8n/config|
Does anybody has a solution for this problem? Thank you!
I thought this file will be created from n8n by the installation process. Where do I get this file or the file structure for this file? I can’t find this information on GitHub.
Ah yes, that file does get auto-generated on the first startup. But if it throws that error there must be a problem with that file. Some ideas:
it got generated on the first start and it got then messed up in between (like for example got overwritten or because of a crash it did not write fully)
I’ve installed the compose file like all the other compose files as “root-user” in the same docker subdirectory (/volume1/docker/n8n). n8n is creating the “config” file in the directory (/volume1/docker/n8n), but the file is empty! I also tried the compose file with PUID and PGID:
|date|stream|content|
|---|---|---|
|2021-03-22 18:57:40|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 18:57:40|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 18:57:28|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 18:57:28|stderr| › Error: There was an error: Error parsing n8n-config file |
|2021-03-22 18:57:15|stdout|Stopping n8n...|
|2021-03-22 18:57:15|stdout||
|2021-03-22 18:57:15|stderr|There was an error initializing DB: getaddrinfo ENOTFOUND postgres|
|2021-03-22 18:57:15|stderr| › "/home/node/.n8n/config". It does not seem to be valid JSON.|
|2021-03-22 18:57:15|stderr| › Error: There was an error: Error parsing n8n-config file|
Hi @Jonathan_English.
I’m 100% sure about that. I had this error and i have manage to fix.
You can try to comment that line and create the volume after that.
As i can see in your logs the first error was at (09:43:03.)
|2021-03-22 09:43:03|stderr|There was an error initializing DB: connect ECONNREFUSED 172.18.0.3:5432|
Run this on your CLI to allow access on the port 5432.
Hi,
Just copy and paste into your Linux terminal.
It seems like your n8n is not able to connect to the database as I can see on your logs.
That command will enable that port to be listened on your firewall.
I’m trying to doing a docker install on my Synology too.
The errors that I see are somewhat similar:
Initializing n8n process
UserSettings got generated and saved to: /home/node/.n8n/config
› Error: There was an error: EACCES: permission denied, open
› ‘/home/node/.n8n/config’
I’ve set all the ENV variables for MySQL and I also set PUID and PGID, but somehow I still get these errors. It seems that it ignores the PUID and PGID, as the folder permissions are changed to ‘root’.
Here’s an attempt running from prompt:
docker run -it --rm --name n8n -p 5678:5678 -v /volume1/docker/n8n:/home/node/.n8n n8nio/n8n n8n start --tunnel
Initializing n8n process
UserSettings got generated and saved to: /home/node/.n8n/config
There was an error initializing DB: “SQLITE_CANTOPEN: unable to open database file”
Stopping n8n…
Hey @Erwin, I have n8n running on Docker (behind a reverse proxy) using the latest official image from the registry.
Here’s a copy of my configuration; try replicating it and let me know if it fixes your issue!
Edit: Just took a second look, it could be that you don’t have write permissions enabled on the volume you used for the n8n container?
Hey @Jonathan_English, could you try adding this to your n8n service configuration in the compose file?
That should make sure that your database service is started before n8n; which may not have happened in your previous compose file; causing it to fail.