title: How to make a Quarkus server starts when its DataSource is unable to connect to the DB or even if the database is down
body: <p>I want to start my quarkus application and if the database is down, it cannot affect my startup.</p>
  <p>My code: <a href="https://github.com/Uenderley/quarkus-datasources" rel="nofollow noreferrer">https://github.com/Uenderley/quarkus-datasources</a></p>
  <p><strong>My pom.xml</strong></p>
  <pre><code>  &lt;properties&gt;
      &lt;compiler-plugin.version&gt;3.8.1&lt;/compiler-plugin.version&gt;
      &lt;maven.compiler.parameters&gt;true&lt;/maven.compiler.parameters&gt;
      &lt;maven.compiler.source&gt;11&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;11&lt;/maven.compiler.target&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;quarkus-plugin.version&gt;1.11.3.Final&lt;/quarkus-plugin.version&gt;
      &lt;quarkus.platform.artifact-id&gt;quarkus-universe-bom&lt;/quarkus.platform.artifact-id&gt;
      &lt;quarkus.platform.group-id&gt;io.quarkus&lt;/quarkus.platform.group-id&gt;
      &lt;quarkus.platform.version&gt;1.11.3.Final&lt;/quarkus.platform.version&gt;
      &lt;surefire-plugin.version&gt;3.0.0-M5&lt;/surefire-plugin.version&gt;
    &lt;/properties&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
        &lt;artifactId&gt;quarkus-hibernate-orm&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
        &lt;artifactId&gt;quarkus-hibernate-orm-panache&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
        &lt;artifactId&gt;quarkus-jdbc-postgresql&lt;/artifactId&gt;
      &lt;/dependency&gt;
  </code></pre>
  <p><strong>application.properties</strong></p>
  <pre><code>quarkus.datasource.db-kind=postgresql
  quarkus.datasource.username=postgres
  quarkus.datasource.password=postgres
  quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5433/users_db
  quarkus.datasource.health.enabled=false
  quarkus.hibernate-orm.database.generation=drop-and-create
  quarkus.datasource.jdbc.min-size=0
  </code></pre>
  <p><strong>Error when I try to start my app when postgres is down</strong></p>
  <pre><code>WARN  [org.hib.eng.jdb.env.int.JdbcEnvironmentInitiator] (Quarkus Main Thread) HHH000342: Could not obtain connection to query metadata: org.postgresql.util.PSQLException: Connection to localhost:5433 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
          at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:303)
          at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
          at org.postgresql.jdbc.PgConnection.&lt;init&gt;(PgConnection.java:225)
          at org.postgresql.Driver.makeConnection(Driver.java:465)
          at org.postgresql.Driver.connect(Driver.java:264)
          at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:200)
          at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:452)
          at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:434)
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:65)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          at java.base/java.lang.Thread.run(Thread.java:834)
  Caused by: java.net.ConnectException: Conexão recusada (Connection refused)
          at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
          at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
          at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
          at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
          at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
          at java.base/java.net.Socket.connect(Socket.java:609)
          at org.postgresql.core.PGStream.createSocket(PGStream.java:231)
          at org.postgresql.core.PGStream.&lt;init&gt;(PGStream.java:95)
          at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:98)
          at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
          ... 12 more
  
  2021-03-03 14:21:56,494 WARN  [io.agr.pool] (agroal-11) Datasource '&lt;default&gt;': Connection to localhost:5433 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
  2021-03-03 14:21:56,495 WARN  [org.hib.eng.jdb.spi.SqlExceptionHelper] (Quarkus Main Thread) SQL Error: 0, SQLState: 08001
  2021-03-03 14:21:56,495 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (Quarkus Main Thread) Connection to localhost:5433 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
  2021-03-03 14:21:56,526 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.net.ConnectException: Conexão recusada (Connection refused)
          at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
          at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
          at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
          at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
          at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
          at java.base/java.net.Socket.connect(Socket.java:609)
          at org.postgresql.core.PGStream.createSocket(PGStream.java:231)
          at org.postgresql.core.PGStream.&lt;init&gt;(PGStream.java:95)
          at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:98)
          at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
          at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
          at org.postgresql.jdbc.PgConnection.&lt;init&gt;(PgConnection.java:225)
          at org.postgresql.Driver.makeConnection(Driver.java:465)
          at org.postgresql.Driver.connect(Driver.java:264)
          at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:200)
          at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:452)
          at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:434)
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:65)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          at java.base/java.lang.Thread.run(Thread.java:834)
  
  Quarkus application exited with code 1
  Press Enter to restart or Ctrl + C to quit
  2021-03-03 14:21:56,528 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure
  </code></pre>
  <p><strong>I know these properties on spring boot:</strong></p>
  <p>spring.datasource.continue-on-error=true</p>
  <p>spring.datasource.initialization-mode=never</p>