I have my app & local machine in the trusted sources of the database. I can connect to the database from my local machine but unable to connect to it from the app platform.
Is this something not supported or am I missing something?
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!
Hello, unfortunately using Trusted Sources with App Platform and PostgreSQL connection pools is not supported, however, we are actively working to support that functionality.
So as a workaround I created an Internal Service that’s only accessible by the other components using a PgBouncer docker image:
The thing is you have to create the service through a yaml file using doctl. It should go under services, here is an example:
services:
- envs:
- key: POOL_MODE
scope: RUN_AND_BUILD_TIME
value: transaction
- key: MAX_CLIENT_CONN
scope: RUN_AND_BUILD_TIME
value: "200"
- key: DEFAULT_POOL_SIZE
scope: RUN_AND_BUILD_TIME
value: "20"
- key: MAX_DB_CONNECTIONS
scope: RUN_AND_BUILD_TIME
value: "40"
- key: SERVER_TLS_SSLMODE
scope: RUN_AND_BUILD_TIME
value: require
- key: DATABASE_URL
scope: RUN_AND_BUILD_TIME
type: SECRET
value: **postgresql://username:password@host:port/dbname**
image:
registry: edoburu
registry_type: DOCKER_HUB
repository: pgbouncer
tag: latest
instance_count: 1
instance_size_slug: professional-xs
internal_ports:
- 5432
name: pgbouncer
I used this docker image: https://hub.docker.com/r/edoburu/pgbouncer/
Once is up and running you can access it from the other components using the component’s name and port, for example:
DATABASE_URL=postgresql://username:password@pgbouncer:5432/dbname
The component is not accessible publicly so it’s secure. Hope it helps.
Regards, Pedro
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.