1

I am trying to setup a chainlink node on my machine. After setting all the .env variables, I am running the docker command to start the node,

cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:0.10.3 local n

but I am getting this error:

pam@g3:~/.chainlink-kovan$ cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:0.10.3 local n
2021-04-07T09:36:21Z [INFO]  Starting Chainlink Node 0.10.3 at commit 5dbbc21f13fa00ee724c439273156834c45ab93e cmd/local_client.go:56  InstanceUUID=f51952e7-d4c9-45f5-b0ae-6e1ed5617bbb SHA=5dbbc21f13fa00ee724c439273156834c45ab93e Version=0.10.3 id=boot 
2021-04-07T09:36:21Z [ERROR] failed to initialize database, got error failed to connect to `host=localhost user=postgres database=postgres`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address) orm/orm.go:82           stacktrace=github.com/smartcontractkit/chainlink/core/store/orm.NewORM
        /chainlink/core/store/orm/orm.go:82
github.com/smartcontractkit/chainlink/core/store.initializeORM
        /chainlink/core/store/store.go:250
github.com/smartcontractkit/chainlink/core/store.newStoreWithKeyStore
        /chainlink/core/store/store.go:87
github.com/smartcontractkit/chainlink/core/store.NewStore
        /chainlink/core/store/store.go:66
github.com/smartcontractkit/chainlink/core/services/chainlink.NewApplication
        /chainlink/core/services/chainlink/application.go:135
github.com/smartcontractkit/chainlink/core/cmd.ChainlinkAppFactory.NewApplication
        /chainlink/core/cmd/client.go:85
github.com/smartcontractkit/chainlink/core/cmd.(*Client).RunNode
        /chainlink/core/cmd/local_client.go:58
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:204 
creating application: failed to initialize ORM: initializeORM#NewORM: unable to init DB: unable to open postgresql://postgres:12345678@localhost:5432/postgres?application_name=Chainlink+0.10.3+%7C+ORM+%7C+f51952e7-d4c9-45f5-b0ae-6e1ed5617bbb for gorm DB: failed to connect to `host=localhost user=postgres database=postgres`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)

I thought this error is coming from postgres, so I tried to connect to postgres through nodejs, which worked.

const { Client } = require("pg");

const client = new Client({
  user: "postgres",
  host: "localhost",
  database: "postgres",
  password: "12345678",
  port: 5432,
});

async function main() {
  await client.connect();
  console.log("Connection Successful.");

  return process.exit(0);
}
main();
1
2

The error was arriving because I was running postgres on my local machine for which I have to add --network host in the end.

Updated Command

docker run --name chainlink-kovan --network host -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:0.10.3 local n

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.