Each project can have its own PostgreSQL and Redis databases. They run beside your app on the project's private network, and your app reaches them with the internal connection string the dashboard gives you.
What each database type offers
| PostgreSQL | Redis | |
|---|---|---|
| Version | 16 | 7 |
| Memory | 256 MB reserved, up to 512 MB | 64 MB reserved, up to 128 MB |
| Storage reserved | 5 GB | 5 GB |
| Scheduled backups | Yes | Yes, database 0 only |
| SQL editor | Yes | No |
| Import a dump | Yes | No |
| External access | Yes | No |
The PostgreSQL and Redis pages have the details for each.
Create a database
- Open your project and go to Databases.
- Click Create database.
- Enter a Database name and choose the Database type.
- Click Create database.
The new database shows as Creating while HCode sets it up, and the page refreshes itself until it reads Running. The connection string is available from the start.
If your plan includes backups, the database gets a daily backup schedule when it is created. See Scheduled backups.
How many databases you can have
Your plan sets how many databases your organisation can have, counted across all of its projects. At the limit, Create database is disabled and the page tells you, for example: "You've used 1 of 1 database on your plan. Delete one or upgrade to add another."
Your plan's limit is shown on the Subscription page. A running database's memory reservation counts toward your plan's memory, and its data and backup files count toward your storage. See Usage and limits.
Connect your app
Each database card has an Internal connection box with a button to reveal the connection string and one to copy it.
- Copy the internal connection string.
- Add it to your project as an environment variable, such as
DATABASE_URLorREDIS_URL. See Environment variables. - Redeploy or restart the app so it reads the new value.
HCode does not set the variable for you, so use the name your framework or library expects.
The host in that string only resolves inside your project. Your other projects can't reach the database, and neither can anyone else's. To connect from your own machine or from another service, turn on external access, which is available for PostgreSQL.
Databases are not reachable during the build
Your app can reach its databases once it is running, not while it is being built. A build that tries to connect fails with "The build tried to connect to your HCode database, but HCode databases can't be reached while your app is being built."
Move migrations and other database steps out of the build command and into the start command, so they run when the app starts. Build failures covers this and other build errors.
Delete a database
- On the database's card, click Delete.
- Confirm the prompt. It warns that the delete "cannot be undone."
Once it is deleted, its backups no longer appear in the dashboard either. If you might need the data later, download a backup first.
Owners, admins and members can create and delete databases. Viewers can see them but can't change them. See Roles and permissions.