Question

Access for DO app to a connection pool hosted by a separate postgres DB server

Hi Everyone, We have a nodeJS API app that runs and connects to an entirely separate postgres 12 server that was provisioned outside of the DO app but runs in the same DO account/region etc. as the app does (the DB is just not listed when you go into look at the app details).

I’ve added the “app” as a trusted source in the database config, I setup a connection pool for this server, expecting to be able to update the DB connection string in API app and see it working without issue, but it looks like the API app is not timing out trying to connect to the DB server going through the connection pool but works fine when directly connecting to it.

I’ve even tested the connection pool to make sure it’s working by connecting through my postico postgres client, so I know the details should be correct.

Is there some undocumented thing about apps not being able to connect to a connection pool for a server that’s been separately provisioned and not as part of an app?

I thought it would have no issue working as the app is clearly listed as a trusted source, but figure maybe someone could help me before I start spinning up a DB server in the app and trying it that way.

Many thanks,

Dan.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
October 16, 2023
Accepted Answer

Hi there,

Indeed, in the past connection pools were not supported in App Platform using trusted sources. But a fix was introduced a few months ago and it should work as expected now.

For example, if you connect your DigitalOcean database to an App Platform app as mydb component, and that database has a connection pool mypool, you can use bindable variables to automatically integrate it into your app as a trusted connection. An example environment variable would be:

${mydb.mypool.DATABASE_URL}

See the documentation.

But in your case, as the database is not assigned to the app in question this might be causing the problem. Is there an option for you to attach the database to the app? If not, you could try reaching out to the DigitalOcean support team who might be able to advise you further:

https://www.digitalocean.com/support/

Hope that helps!

- Bobby.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel