NEW

Connect the world's APIs to Web3 with Chainlink Functions. Get started

Connecting to a Remote Database

This page will serve as a basic, vendor-neutral guide for setting up a PostgreSQL database and connecting your Chainlink node to it.

PostgreSQL is a popular and secure database available on a variety of platforms. This guide will not show you how to create and set up a PostgreSQL database, however, some common guides can be found below:

Obtain Information About Your Database

In order to connect to a remote database, you will need to obtain information about the database and server. Take note of the database’s:

  • Server 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:

DATABASE_URL=postgresql://$USERNAME:$PASSWORD@$SERVER:$PORT/$DATABASE

You will need to change the following placeholders to their real values:

  • $USERNAME: The database username (must be owner)
  • $PASSWORD: The user’s password
  • $SERVER: The server name or IP address of the database server
  • $PORT: The port that the database is listening on
  • $DATABASE: The database to use for the Chainlink node

What's next

Stay updated on the latest Chainlink news