Running a Chainlink Node
This guide will teach you how to run a Chainlink node locally using Docker. The Chainlink node will be configured to connect to the Ethereum Sepolia or Goerli testnet.
Requirements
- As explained in the requirements page, make sure there are enough resources to run a Chainlink node and a PostgreSQL database.
- Install Docker Desktop. You will run the Chainlink node and PostgreSQL in Docker containers.
- Chainlink nodes must be able to connect to an Ethereum client with an active websocket connection. See Running an Ethereum Client for details. In this tutorial, you can use an external service as your client.
Using Docker
Run PostgreSQL
-
Run PostgreSQL in a Docker container. You can replace
mysecretpasswordwith your own password.docker run --name cl-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres -
Confirm that the container is running. Note the
5432port is published0.0.0.0:5432->5432/tcpand therefore accessible outside of Docker.docker ps -a -f name=cl-postgresIf the container is running successfully, the output shows a healthy status:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES dc08cfad2a16 postgres "docker-entrypoint.s…" 3 minutes ago Up 3 minutes 0.0.0.0:5432->5432/tcp cl-postgres
Run Chainlink node
Configure your node
-
Create a local directory to hold the Chainlink data:
mkdir ~/.chainlink-sepoliamkdir ~/.chainlink-goerli -
Run the following as a command to create a
config.tomlfile and populate with variables specific to the network you're running on. For a full list of available configuration variables, see the Node Config page. Be sure to update the value forCHANGEMEto the value given by your external Ethereum provider.echo "[Log] Level = 'warn' [WebServer] AllowOrigins = '\*' SecureCookies = false [WebServer.TLS] HTTPSPort = 0 [[EVM]] ChainID = '11155111' [[EVM.Nodes]] Name = 'Sepolia' WSURL = 'wss://CHANGE_ME' HTTPURL = 'https://CHANGE_ME' " > ~/.chainlink-sepolia/config.tomlecho "[Log] Level = 'warn' [WebServer] AllowOrigins = '*' SecureCookies = false [WebServer.TLS] HTTPSPort = 0 [[EVM]] ChainID = '5' [[EVM.Nodes]] Name = 'Goerli' WSURL = 'wss://CHANGE_ME' HTTPURL = 'https://CHANGE_ME' " > ~/.chainlink-goerli/config.toml -
Create a
secrets.tomlfile with a keystore password and the URL to your database. Update the value formysecretpasswordto the chosen password in Run PostgreSQL. Specify a complex keystore password. This will be your wallet password that you can use to unlock the keystore file generated for you.echo "[Password] Keystore = 'mysecretkeystorepassword' [Database] URL = 'postgresql://postgres:mysecretpassword@host.docker.internal:5432/postgres?sslmode=disable' " > ~/.chainlink-sepolia/secrets.tomlecho "[Password] Keystore = 'mysecretkeystorepassword' [Database] URL = 'postgresql://postgres:mysecretpassword@host.docker.internal:5432/postgres?sslmode=disable' " > ~/.chainlink-goerli/secrets.toml -
Create an
.apifile with your API credentials. The API email and password will be used to expose the API for the GUI interface, and you will use these credentials every time you log into your node.Create the file in the same directory as your TOML config files and list your API credentials. Change the values for API email and password, making sure that the password is 16-50 characters in length.
echo "CHANGE_THIS_API_EXAMPLE_EMAIL@example.com CHANGE_THIS_EXAMPLE_TEST_API_PASSWORD " > ~/.chainlink-sepolia/.apiecho "CHANGE_THIS_API_EXAMPLE_EMAIL@example.com CHANGE_THIS_EXAMPLE_TEST_API_PASSWORD " > ~/.chainlink-goerli/.apiIn the next step, when you run the Docker image, include the
.apifile at the end of thedocker runcommand using the-aflag:docker run \ ... node start \ -a /chainlink/.api -
Start the Chainlink Node by running the Docker image.
Change the version number in
smartcontract/chainlink:2.0.0with the version of the Docker image that you need to run. For most new nodes, use version2.0.0or later. Tag versions are available in the Chainlink Docker hub. Thelatestversion does not work.Chainlink Nodes running
2.0.0and later require the-configand-secretsflags after thenodepart of the command. Versions1.13.1and earlier require the-configand-secretsflags to be placed before thenode startportion of the command.cd ~/.chainlink-sepolia && docker run --platform linux/x86_64/v8 --name chainlink-4 -v ~/.chainlink-sepolia:/chainlink -it -p 6688:6688 --add-host=host.docker.internal:host-gateway smartcontract/chainlink:2.0.0 node -config /chainlink/config.toml -secrets /chainlink/secrets.toml start -a /chainlink/.apicd ~/.chainlink-goerli && docker run --platform linux/x86_64/v8 --name chainlink -v ~/.chainlink-goerli:/chainlink -it -p 6688:6688 --add-host=host.docker.internal:host-gateway smartcontract/chainlink:2.0.0 node -config /chainlink/config.toml -secrets /chainlink/secrets.toml start -a /chainlink/.apicd ~/.chainlink-sepolia && docker run --platform linux/x86_64/v8 --name chainlink -v ~/.chainlink-sepolia:/chainlink -it -p 6688:6688 --add-host=host.docker.internal:host-gateway smartcontract/chainlink:1.13.1 -config /chainlink/config.toml -secrets /chainlink/secrets.toml node start -a /chainlink/.apicd ~/.chainlink-goerli && docker run platform linux/x86_64/v8 --name chainlink -v ~/.chainlink-goerli:/chainlink -it -p 6688:6688 --add-host=host.docker.internal:host-gateway smartcontract/chainlink:1.13.1 -config /chainlink/config.toml -secrets /chainlink/secrets.toml node start -a /chainlink/.api -
Confirm that the container is running. Note that the
6688port is published0.0.0.0:6688->6688/tcpand is accessible outside of Docker.docker ps -a -f name=chainlinkIf the container is running, the output shows a healthy status:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES feff39f340d6 smartcontract/chainlink:1.13.0 "chainlink node start" 4 minutes ago Up 4 minutes (healthy) 0.0.0.0:6688->6688/tcp chainlink -
You can now connect to your Chainlink node's UI interface by navigating to http://localhost:6688. Use the API credentials you set up earlier to log in.
If you are using a VPS, you can create an SSH tunnel to your node for
6688:localhost:6688to enable connectivity to the GUI. Typically this is done withssh -i $KEY $USER@$REMOTE-IP -L 6688:localhost:6688 -N. An SSH tunnel is recommended over opening public-facing ports specific to the Chainlink node. See the Security and Operation Best Practices page for more details about securing your node.