Connection details are unavailable while the database is being provisioned.

Posted December 21, 2021 208 views
Node.jsDigitalOcean 1-Click Apps Marketplace

Hi 👋

I have trouble starting my App! It fails in the deployment phase (build is ✅) because to start it needs to have a database set up.

This is your most ordinary NodeJS app that uses a persistent session storage.

Here’s the output of my build:

[2021-12-20 14:57:08] yarn run v1.22.17
[2021-12-20 14:57:08] $ NODE_ENV=production node build/server.js
[2021-12-20 14:57:10] > App started http://localhost:3000
[2021-12-20 14:57:10] node:internal/process/promises:246
[2021-12-20 14:57:10]           triggerUncaughtException(err, true /* fromPromise */);
[2021-12-20 14:57:10]           ^
[2021-12-20 14:57:10] 
[2021-12-20 14:57:10] Error: getaddrinfo ENOTFOUND my_db
[2021-12-20 14:57:10]     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
[2021-12-20 14:57:10]   errno: -3008,
[2021-12-20 14:57:10]   code: 'ENOTFOUND',
[2021-12-20 14:57:10]   syscall: 'getaddrinfo',
[2021-12-20 14:57:10]   hostname: 'my_db'
[2021-12-20 14:57:10] }
[2021-12-20 14:57:10] error Command failed with exit code 1.
[2021-12-20 14:57:10] info Visit for documentation about this command.

This means that the db is not yet ready so my app can’t connect.
When I go to Settings > db (this is a dev database), at the connection details I see:

Connection details are unavailable while the database is being provisioned.

So I’m a bit confused about how can I get my app to start if it needs a database.


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hey there!

This error you are seeing is common when an application attempts to connect to the database during the build phase of your applications deployment process. With dev database’s they aren’t able to be connected to during the build phase and should be connected to during the run phase. I’d recommend modifying your application to connect during runtime rather then build if you would like to use a dev database.

If you need to connect during build then I’d recommend using a managed database instead. You would be able to connect to a managed database during build.

Managed Databases

Hope it helps!

  • Thanks for the answer.
    Sorry, I made a typo above and I can’t edit the post.

    The log I shared is the deployment log.

    My build phase passes without errors.

    My app doesn’t try to connect to any database during the build phase.

    • Any idea @njw why this is still not working even after a successful build phase?

      • If that connection is happening during the run phase of the build then there may be something else going on there with your database connection ENV variables or settings. You may want to open a ticket and our support team can take a better look at the settings of those variables.

        • Where should I create this ticket?

          Also, do you know why my comments and posts take hours to get verified?

          The connection failure is happening in the Deployment phase.

          My logs look kind of like this:

          Build logs
           - ✔️ my-project
          Deploy logs
           - ❗️ my project

          While the full error is:

          [2022-01-04 17:47:23] yarn run v1.22.17
          [2022-01-04 17:47:23] $ NODE_ENV=production node build/server.js
          [2022-01-04 17:47:25] > App started http://localhost:3000
          [2022-01-04 17:47:25] node:internal/process/promises:246
          [2022-01-04 17:47:25]           triggerUncaughtException(err, true /* fromPromise */);
          [2022-01-04 17:47:25]           ^
          [2022-01-04 17:47:25] 
          [2022-01-04 17:47:25] Error: connect ECONNREFUSED
          [2022-01-04 17:47:25]     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
          [2022-01-04 17:47:25]   errno: -111,
          [2022-01-04 17:47:25]   code: 'ECONNREFUSED',
          [2022-01-04 17:47:25]   syscall: 'connect',
          [2022-01-04 17:47:25]   address: '',
          [2022-01-04 17:47:25]   port: 5432
          [2022-01-04 17:47:25] }
          [2022-01-04 17:47:25] error Command failed with exit code 1.
          [2022-01-04 17:47:25] info Visit for documentation about this command.

Encountered the same issue in one of my project and trying to find a solution for the last three days.