Connect to a managed database
A managed database runs on its own server that we keep updated. Your app connects to it with a host, port, user and password, over an encrypted connection. This article covers finding those details, letting your app in, and connecting a site on your Barbrick hosting.
Find the connection details
- Open your database from Services, then Connect.
- Connection details lists the Host, Port, User and Database. Choose Copy beside each.
- Choose Show password and confirm. We show the password once, so copy it into a password manager before you close the box.
Connection strings has ready-made examples for common languages. Replace YOUR_PASSWORD with the password. A PostgreSQL example looks like this:
postgresql://app:[email protected]:25060/app?sslmode=require
Connections must be encrypted. Use sslmode=require for PostgreSQL or ssl-mode=REQUIRED for MySQL. Both encrypt the connection without checking the name on the certificate. Your host ends in barbrick.cloud, but the certificate names the server behind it, so a library that checks the name refuses to connect. Don't use verify-full or VERIFY_IDENTITY. The examples under Connection strings are already set up this way.
If the host says it's being prepared, the database is still being set up. Check back in a few minutes.
Choose who can connect
Only addresses in Who can connect reach the database. Everything else is blocked.
- Under Address or range, enter your app server's address, like
203.0.113.7. Choose Use my address to add the computer you're on. - Choose Allow.
To let one of your Barbrick hosting accounts in, choose Allow with its domain. We don't allow wide ranges, such as 0.0.0.0/0 or anything bigger than a /16 (/48 for IPv6), because they would open the database to much of the internet.
Connect a site on your hosting
- Under Connect to my hosting site, pick the Hosting account, then the Site.
- If you've already seen the password, enter it in Database password. We need it to add the settings to your app.
- Choose Connect.
We let the hosting account in. For Node.js and Python apps, we also add DATABASE_URL and the separate DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD settings to the app and restart it. For WordPress and other sites, the panel shows the lines to paste into the site's settings file, such as wp-config.php.
Reset the password
Choose Reset beside Password and confirm. The new password is shown once. Apps using the old one stop connecting until you update them.
Where your data is stored
Your database is hosted in Canadian datacentres. Canadian regions of US-owned providers remain subject to US law, including the CLOUD Act. See Where your data is stored.
If something goes wrong
- The connection times out. Your app's address isn't in Who can connect. Add it.
SSL required. Turn on SSL in your library's settings, withsslmode=requireorssl-mode=REQUIRED.- A certificate or host name error. Your library is checking the certificate's name. Switch it to
requiremode, as in the examples under Connection strings. password authentication failed. Check the password in your password manager, or reset it.
Still stuck? Ask us and we'll walk you through it.
