Database is not ready!

Hello n8n community,

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.

Thanks,

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hey @dse,

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?

Hi Jon,

Thanks for you reply.

The database is not running in container.
Yes, sorry for the confusion, I meant the n8n container.

I don’t know if there is some kind of keepalive in n8n, so as not to lose the connection between the n8n container and the postgresql database.

Hey @dse,

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?

Hi @Jon,

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.

Thanks,

Hey @dse,

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.

Hi @Jon,

Thanks a lot for your support.
I’ll try to discuss with our DB Admin and network team.

Thanks

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