I have a problem accessing the n8n UI, I get this error message “Database is not ready!” Error code = 503.
In n8n logs I have this error and I think that is related to database connection.
{“level”:“error”,“message”:“Error: Connection terminated unexpectedly”,“metadata”:{“file”:“LoggerProxy.js”,“function”:“exports.error”,“timestamp”:“2024-09-13T07:18:31.199Z”}}
I’ve checked my database, the status is Up and I can run sql queries as well.
The workaround, is to restart docker manually (but I need to know the root cause of this issue).
Do you have any idea how to fix this issue?
About my envirenment:
n8n = self-hosted mode
n8n version = 1.50.1
database =postgresql v14.11
OS = linux RedHat 11.4
n8n running in docker.
The message in the UI is n8n saying it can’t connect to the database, This fits with the log error you are seeing as welll.
I am not sure why this would be happening, Are you also running the database in container? When you say you restart Docker what is it you are restarting the Docker service, the n8n container or something else?
There should be but it could be that the connection to the database is a bit dodgy at times. If the database isn’t in a container is it on another host or directly installed on the docker host?
No, the database is installed on another host.
I’ll ask our DB Admin, if there is some custom configuration in postgresql database wich causes n8n disconnect.
If it is on another host it could be a network timeout as well, DB_POSTGRESDB_CONNECTION_TIMEOUT controls the timeout and the default value is 20000 (20 seconds).
The error itself though is saying the connection was closed so it could be that the database was restarted or something odd happened on the network between docker, the docker host and the database server.