'Cannot boot Chainlink: opening db: failed to open db:
When I "chainlink node start", I get the error:
"Cannot boot Chainlink: opening db: failed to open db: failed to connect to host=/private/tmp user=myname database=
: server error (FATAL: unrecognized configuration parameter "?application_name" (SQLSTATE 42704))"
I follow this youtube video: https://youtu.be/ZB3GLtQvgME?t=2017 I have a .env but it is not reading from there. No matter what I change on DATABASE_URL, I get the same error.
ETH_URL=wss://kovan.infura.io/ws/v3/
FEATURE_EXTERNAL_INITIATORS=true
LOG_LEVEL=debug
ETH_CHAIN_ID=42
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
ALLOW_ORIGINS=*
DATABASE_URL=postgresql://localhost:5432/kovan_demo?sslmode=disable
DATABASE_TIMEOUT=0
FEATURE_FLUX_MONITOR=true
MINIMUM_CONTRACT_PAYMENT=0
CHAINLINK_DEV=true
Solution 1:[1]
The database parameters are set via environment variable
Solution 2:[2]
As Richard said, you need to set DATABASE_URL
as an environment variable. For some reason, the chainlink client cannot read file .env
and set the environment variable as expected.
The way how I solve the problem is to set DATABASE_URL
as an environment variable explicitly by command:
export DATABASE_URL=postgresql://<usrname>:<passswd>@localhost:5432/chainlink_node?sslmode=disable
You can find all configurations of Chainlink node here.
Hope it helps.
Solution 3:[3]
The format to connect to the database is the following:
DATABASE_URL=postgresql://$USERNAME:$PASSWORD@$SERVER:$PORT/$DATABASE
I always follow this steps to create the database:
sudo -u postgres psql
create database $DATABASE;
create user $USERNAME with encrypted password '$PASSWORD';
grant all privileges on database $DATABASE to $USERNAME;
Just change the variables
sudo -u postgres psql
create database chainlink;
create user username with encrypted password 'pass';
grant all privileges on database chainlink to username;
And then:
DATABASE_URL=postgresql://username:pass@localhost:5432/chainlink?sslmode=disable
I don't recommend at all this credentials for production.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Richard G |
Solution 2 | |
Solution 3 | Matias |