Create a database and connect it to an AI-built website
Create a PostgreSQL database and add its connection URL to an application variable.
In this guide
Before you start
You need service management permissions, an available database slot and a website to connect. Check which database type and variable name the application expects.
Create and connect the database
- Return to the service view in the dashboard and open Databases → New database.
- Choose the type your application needs from the available options.
- Enter a name: 3–32 characters using lowercase a–z, digits and underscores, starting with a letter. Select Create database and wait for completion.
- Select the database's Connect to a website action and choose the correct website. Staging environments are labeled separately.
- Enter the variable name expected by the application. Review the warning if the variable already has a value: the connection URL will replace it.
- Select Connect. The website is redeployed to apply the connection.
Verify the result
Test reading and saving data in the application. Connecting adds the connection URL, but the application must still use it and create its tables through its own migration process. Check the website log for errors.
Develop on your own computer
Your application reads the database's address from a variable, such as process.env.DATABASE_URL. On your own computer, use a PostgreSQL database of your own and put its address in a .env file that you keep out of your repository. Here, the dashboard gives the same variable this database's address, so the same code works in both places. The database can only be reached from our servers. To look at your data from your own computer or to move an old database here, see Use your database from your own computer.
Passwords and connection problems
Show password reveals credentials and the connection URL when needed. Keep them out of public repositories. Change password updates websites connected through the dashboard and redeploys them; update credentials copied manually elsewhere separately. If the connection fails, check database status, the variable name and the application's database driver.
