2

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

3 Answers3

0

The database parameters are set via environment variable

Richard G
  • 163
  • 5
  • I follow this youtube video: https://www.youtube.com/watch?v=ZB3GLtQvgME&t=2278s I did have a .env but it is not reading from there. 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 – johnnybegoode Mar 03 '22 at 20:36
  • Are you able to connect to your database locally via `psql -d kovan_demo -h localhost` – Richard G Mar 04 '22 at 19:44
  • Yes `$ psql -d kovan_demo -h localhost psql (14.2) Type "help" for help. kovan_demo=#` – johnnybegoode Mar 05 '22 at 20:14
  • I also get `opening db: failed to open db: failed to connect to `host=localhost user=root database=kovan_demo`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)` when I `docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:1.1.1 local n ` – johnnybegoode Mar 05 '22 at 22:46
0

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.

Frank Kong
  • 1,010
  • 1
  • 20
  • 32
-1

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.

Matias
  • 1
  • This is what happened if I use Docker: `opening db: failed to open db: failed to connect to 'host=localhost user=username database=chainlink': dial error (dial tcp [::1]:5432: connect: cannot assign requested address)` – johnnybegoode Mar 22 '22 at 03:06
  • Same original error without the use of Docker. – johnnybegoode Mar 22 '22 at 03:40
  • When you are started the chainlink node with docker, did you set this flag `--network host`? Try something like: `cd ~/.chainlink-rinkeby && docker run -p 6688:6688 -v ~/.chainlink-rinkeby:/chainlink -it --env-file=.env --network host smartcontract/chainlink: local n` – Matias Mar 23 '22 at 21:09