简体   繁体   中英

docker chainlink container not connecting to postgres database

I want to run chainlink node on my local ubuntu machine. I used the following commands to install postgresql:

sudo apt install postgresql

adjusting firewall settings:

sudo ufw allow from any to any port 5432 proto tcp

accessing postgresql.conf file:

sudo gedit /etc/postgresql/12/main/postgresql.conf

alter file to

listen_addresses = ‘*’

sudo gedit /etc/postgresql/14/main/pg_hba.conf

alter file to

host all all 172.17.0.0/16     md5

created user and databases see the image below: [![this image shows my databases and users in postgresql][1]][1]

configuration of my .env file is:

ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=42
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=0xa36085F69e2889c224210F603D836748e7dC0088
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
GAS_UPDATER_ENABLED=true
ALLOW_ORIGINS=*
ETH_URL=wss://kovan.infura.io/ws/v3/f0d1d3d2fbb649e29922ec37d4ff0b45
DATABASE_URL=postgresql://chainlink:password#123@127.0.0.1:5432/chainlink?ssl=disable
DATABASE_TIMEOUT=0

I run the following command in the terminal with an image version of 0.10.14.

cd ~/.chainlink-kovan && docker run -p 6688:6688 --name chainlink-node --add- 
host=host:127.0.0.1 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env 
smartcontract/chainlink:0.10.14 local n

it is not connecting to postgresql database. sometime it shows the error that DATABASE_URL line is wrong in .env file. current error log is:

    {"level":"warn","ts":1634243680.5286717,"caller":"logger/default.go:134","msg":"GAS_UPDATER_ENABLED has been deprecated, to enable the block history estimator, please use GAS_ESTIMATOR_MODE=BlockHistory instead"}
2021-10-14T20:34:40Z [INFO]  Starting Chainlink Node 0.10.14 at commit 8160d7726d778b5c425e4b56af30b76cbc6d222d cmd/local_client.go:63  InstanceUUID=c6169db0-8d75-4902-becc-643bb0672861 SHA=8160d7726d778b5c425e4b56af30b76cbc6d222d Version=0.10.14 id=boot 
2021-10-14T20:34:40Z [ERROR] invalid database url %spostgresql://chainlink:Kashif#143@127.0.0.1:5939/chainlink?ssl=disable config/config.go:372    stacktrace=github.com/smartcontractkit/chainlink/core/store/config.Config.DatabaseURL
    /chainlink/core/store/config/config.go:372
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
    /chainlink/core/cmd/client.go:86
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
    /chainlink/core/cmd/local_client.go:76
github.com/urfave/cli.HandleAction
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:524
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:173
github.com/urfave/cli.(*App).RunAsSubcommand
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:405
github.com/urfave/cli.Command.startApp
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:372
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:102
github.com/urfave/cli.(*App).Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:277
main.Run
    /chainlink/core/main.go:20
main.main
    /chainlink/core/main.go:14
runtime.main
    /usr/local/go/src/runtime/proc.go:225 
2021-10-14T20:34:40Z [ERROR] invalid database url %spostgresql://chainlink:Kashif#143@127.0.0.1:5939/chainlink?ssl=disable config/config.go:372    stacktrace=github.com/smartcontractkit/chainlink/core/store/config.Config.DatabaseURL
    /chainlink/core/store/config/config.go:372
github.com/smartcontractkit/chainlink/core/store.initializeORM
    /chainlink/core/store/store.go:167
github.com/smartcontractkit/chainlink/core/store.newStore
    /chainlink/core/store/store.go:69
github.com/smartcontractkit/chainlink/core/store.NewStore
    /chainlink/core/store/store.go:47
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
    /chainlink/core/services/chainlink/application.go:152
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
    /chainlink/core/cmd/client.go:87
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
    /chainlink/core/cmd/local_client.go:76
github.com/urfave/cli.HandleAction
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:524
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:173
github.com/urfave/cli.(*App).RunAsSubcommand
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:405
github.com/urfave/cli.Command.startApp
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:372
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:102
github.com/urfave/cli.(*App).Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:277
main.Run
    /chainlink/core/main.go:20
main.main
    /chainlink/core/main.go:14
runtime.main
    /usr/local/go/src/runtime/proc.go:225 
2021-10-14T20:34:40Z [ERROR] failed to initialize database, got error failed to connect to `host=/tmp user=root database=`: dial error (dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory) orm/orm.go:87           stacktrace=github.com/smartcontractkit/chainlink/core/store/orm.NewORM
    /chainlink/core/store/orm/orm.go:87
github.com/smartcontractkit/chainlink/core/store.initializeORM
    /chainlink/core/store/store.go:168
github.com/smartcontractkit/chainlink/core/store.newStore
    /chainlink/core/store/store.go:69
github.com/smartcontractkit/chainlink/core/store.NewStore
    /chainlink/core/store/store.go:47
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
    /chainlink/core/services/chainlink/application.go:152
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
    /chainlink/core/cmd/client.go:87
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
    /chainlink/core/cmd/local_client.go:76
github.com/urfave/cli.HandleAction
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:524
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:173
github.com/urfave/cli.(*App).RunAsSubcommand
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:405
github.com/urfave/cli.Command.startApp
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:372
github.com/urfave/cli.Command.Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/command.go:102
github.com/urfave/cli.(*App).Run
    /go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:277
main.Run
    /chainlink/core/main.go:20
main.main
    /chainlink/core/main.go:14
runtime.main
    /usr/local/go/src/runtime/proc.go:225 
creating application: failed to initialize ORM: initializeORM#NewORM: unable to init DB: unable to open ?application_name=Chainlink+0.10.14+%7C+ORM+%7C+c6169db0-8d75-4902-becc-643bb0672861 for gorm DB conn &{0 0xc000b46108 0 {0 0} [] map[] 0 0 0xc00045a5a0 false map[] map[] 0 0 0 0 <nil> 0 0 0 0 0x5970a0}: failed to connect to `host=/tmp user=root database=`: dial error (dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory)

For two days I have been stuck in this problem and not able to make any progress. Thank you for your time and effor in anticipation. don't report this question I have tried all other possible ways watched and read all the help availabe online. [1]: https://i.stack.imgur.com/rrT8u.png

problem was in DATABASE_URL variable. I was using # character in my database password. I removed the # and now problem is solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM