NEW

CCIP is now live for all developers. See what's new.

Back

Connecting to a Remote Database

This guide show you how to set up a PostgreSQL database and connect your Chainlink node to it. Alternatively, you can follow the guides below:

Obtain information about your database

In order to connect to a remote database, you must obtain information about the database and the server. Note the following database details so you can use them to configure your Chainlink node later:

  • Server hostname or IP
  • Port
  • Username
  • Password
  • Database name

The user must be the owner of the desired database. On first run, the migrations will create the tables necessary for the Chainlink node.

Set Your DATABASE_URL environment variable

Below is an example for setting the DATABASE_URL environment variable for your Chainlink Node's .env configuration file:

DATABASE_URL=postgresql://[USERNAME]:[PASSWORD]@[SERVER]:[PORT]/[DATABASE]?sslmode=[SSL_MODE]

Change the following placeholders to their real values:

  • [USERNAME]: The username for the database owner account.
  • [PASSWORD]: The password for the database owner account.
  • [SERVER]: The hostname or IP address of the database server.
  • [PORT]: The port that the database is listening on. The default port for PostgreSQL is 5432.
  • [DATABASE]: The name of the database to use for the Chainlink node.
  • [SSL_MODE]: If you are testing on a database that does not have SSL enabled, you can specify disable so that you don't need to go through the process of configuring SSL on your database. On a production node, set this value to require or verify-full. This requires an encrypted connection between your Chainlink node and the database. See the PostgreSQL documentation to learn about the available SSL modes.

What's next

Stay updated on the latest Chainlink news