# Standalone docker keycloak fails to reconnect to the database

**URL:** <https://forum.keycloak.org/t/standalone-docker-keycloak-fails-to-reconnect-to-the-database/11551>\
**Category:** Configuring the server\
**Created:** [October 16, 2021, 8:21am UTC](https://forum.keycloak.org/t/standalone-docker-keycloak-fails-to-reconnect-to-the-database/11551 "2021-10-16T08:21:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![infra-monkey](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/infra-monkey/32/3103_2.png) [@infra-monkey](https://forum.keycloak.org/u/infra-monkey)\
**Post date:** [October 16, 2021, 8:21am UTC](https://forum.keycloak.org/t/standalone-docker-keycloak-fails-to-reconnect-to-the-database/11551/1 "2021-10-16T08:21:45Z")

</div>

Hello,

I have a working keycloak cluster with docker instances on separate nodes clustered with JDBC\_PING.  
When starting the instances **with** external postgresql reachable, everything is fine. Stop the db and restart it later works well. Keycloak automatically reconnects.

The problem I have is when starting keycloak **without connectivity to the db**. In this case the container restarts every N seconds, which is fine (restart=unless-stopped).  
When the db becomes available, keycloak does not detect it on the next start. It just keeps restarting  
The only way to make it work is to do a docker-compose down && docker-compose up -d

Any suggestion on how to make it work properly?
