Search code examples
postgresqlchainlink

CHAINLINK NODE - Start up Issues - Unable to Initialize ORM


Trying to start my node and having errors. Below is the error message. For reference: Using GCP, Ubuntu, Postgres Public db, Docker 0.9.4, and Infura. Replaced my password with PASSWORD in error message, but was entered correctly during testing. I'm close, I believe, just need some help getting over this final hurdle. Thank you!

cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:0.9.4 local n
2021-07-12T20:46:51Z [INFO]  Starting Chainlink Node 0.9.4 at commit b7d22afdae61fc9146136e8518c221d406d10d6d cmd/local_client.go:51
2021-07-12T20:46:51Z [INFO]  Locking postgres for exclusive access with 500ms timeout orm/orm.go:69
2021-07-12T20:49:01Z [ERROR] unable to lock ORM: dial tcp 35.222.48.64:5432: connect: connection timed out logger/default.go:155   stacktrace=github.com/smartcontractkit/chainlink/core/logger.Errorf
        /chainlink/core/logger/default.go:155
github.com/smartcontractkit/chainlink/core/store/orm.(*ORM).MustEnsureAdvisoryLock
        /chainlink/core/store/orm/orm.go:91
github.com/smartcontractkit/chainlink/core/store/orm.NewORM
        /chainlink/core/store/orm/orm.go:75
github.com/smartcontractkit/chainlink/core/store.initializeORM
        /chainlink/core/store/store.go:176
github.com/smartcontractkit/chainlink/core/store.newStoreWithKeyStore
        /chainlink/core/store/store.go:78
github.com/smartcontractkit/chainlink/core/store.NewStore
        /chainlink/core/store/store.go:57
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
        /chainlink/core/services/chainlink/application.go:97
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
        /chainlink/core/cmd/client.go:84
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
        /chainlink/core/cmd/local_client.go:53
github.com/urfave/cli.HandleAction
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:526
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:174
github.com/urfave/cli.(*App).RunAsSubcommand
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:407
github.com/urfave/cli.Command.startApp
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:373
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:102
github.com/urfave/cli.(*App).Run
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:279
main.Run
        /chainlink/core/main.go:18
main.main
        /chainlink/core/main.go:12
runtime.main
        /usr/local/go/src/runtime/proc.go:204
2021-07-12T20:51:12Z [FATAL] Unable to initialize ORM: dial tcp 35.222.48.64:5432: connect: connection timed out
unable to open postgresql://chainlink-db-user:[email protected]:5432/chainlink-kovan-db for gorm DB
github.com/smartcontractkit/chainlink/core/store/orm.Connection.initializeDatabase
        /chainlink/core/store/orm/orm.go:1618
github.com/smartcontractkit/chainlink/core/store/orm.NewORM
        /chainlink/core/store/orm/orm.go:77
github.com/smartcontractkit/chainlink/core/store.initializeORM
        /chainlink/core/store/store.go:176
github.com/smartcontractkit/chainlink/core/store.newStoreWithKeyStore
        /chainlink/core/store/store.go:78
github.com/smartcontractkit/chainlink/core/store.NewStore
        /chainlink/core/store/store.go:57
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
        /chainlink/core/services/chainlink/application.go:97
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
        /chainlink/core/cmd/client.go:84
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
        /chainlink/core/cmd/local_client.go:53
github.com/urfave/cli.HandleAction
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:526
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:174
github.com/urfave/cli.(*App).RunAsSubcommand
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:407
github.com/urfave/cli.Command.startApp
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:373
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:102
github.com/urfave/cli.(*App).Run
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:279
main.Run
        /chainlink/core/main.go:18
main.main
        /chainlink/core/main.go:12
runtime.main
        /usr/local/go/src/runtime/proc.go:204
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1374
unable to init DB
github.com/smartcontractkit/chainlink/core/store/orm.NewORM
        /chainlink/core/store/orm/orm.go:79
github.com/smartcontractkit/chainlink/core/store.initializeORM
        /chainlink/core/store/store.go:176
github.com/smartcontractkit/chainlink/core/store.newStoreWithKeyStore
        /chainlink/core/store/store.go:78
github.com/smartcontractkit/chainlink/core/store.NewStore
        /chainlink/core/store/store.go:57
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
        /chainlink/core/services/chainlink/application.go:97
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
        /chainlink/core/cmd/client.go:84
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
        /chainlink/core/cmd/local_client.go:53
github.com/urfave/cli.HandleAction
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:526
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:174
github.com/urfave/cli.(*App).RunAsSubcommand
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:407
github.com/urfave/cli.Command.startApp
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:373
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:102
github.com/urfave/cli.(*App).Run
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:279
main.Run
        /chainlink/core/main.go:18
main.main
        /chainlink/core/main.go:12
runtime.main
        /usr/local/go/src/runtime/proc.go:204
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1374
initializeORM#NewORM
github.com/smartcontractkit/chainlink/core/store.initializeORM
        /chainlink/core/store/store.go:178
github.com/smartcontractkit/chainlink/core/store.newStoreWithKeyStore
        /chainlink/core/store/store.go:78
github.com/smartcontractkit/chainlink/core/store.NewStore
        /chainlink/core/store/store.go:57
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
        /chainlink/core/services/chainlink/application.go:97
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
        /chainlink/core/cmd/client.go:84
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
        /chainlink/core/cmd/local_client.go:53
github.com/urfave/cli.HandleAction
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:526
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:174
github.com/urfave/cli.(*App).RunAsSubcommand
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:407
github.com/urfave/cli.Command.startApp
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:373
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:102
github.com/urfave/cli.(*App).Run
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:279
main.Run
        /chainlink/core/main.go:18
main.main
        /chainlink/core/main.go:12
runtime.main
        /usr/local/go/src/runtime/proc.go:204
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1374 store/store.go:80       stacktrace=github.com/smartcontractkit/chainlink/core/store.newStoreWithKeyStore
        /chainlink/core/store/store.go:80
github.com/smartcontractkit/chainlink/core/store.NewStore
        /chainlink/core/store/store.go:57
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
        /chainlink/core/services/chainlink/application.go:97
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
        /chainlink/core/cmd/client.go:84
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
        /chainlink/core/cmd/local_client.go:53
github.com/urfave/cli.HandleAction
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:526
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:174
github.com/urfave/cli.(*App).RunAsSubcommand
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:407
github.com/urfave/cli.Command.startApp
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:373
github.com/urfave/cli.Command.Run
        /go/pkg/mod/github.com/urfave/[email protected]/command.go:102
github.com/urfave/cli.(*App).Run
        /go/pkg/mod/github.com/urfave/[email protected]/app.go:279
main.Run
        /chainlink/core/main.go:18
main.main
        /chainlink/core/main.go:12
runtime.main
        /usr/local/go/src/runtime/proc.go:204

Solution

  • If you have your virtual machine for the Chainlink node (Ubuntu) and your PostgreSQL server with its database hosted in the same virtual private cloud on GCP, then it is recommended to take out the public IP of the postgres server and create an internal IP. You can change this in the postgres settings under "Connections". Then add this private IP (10.x.x.x) to your DATABASE_URL config in your environmental file. The Chainlink node should now be able to establish a connection. Please ensure that you remove the Chainlink node before a reinitialisation.

    1. You can check all current containers (including the killed ones) with :docker ps -a
    2. kill a container with: docker kill <container-name>
    3. remove a container with: docker rm <container-name>

    Then finally just reinitialize the node with your run command.