Marketplace has launched, further enabling blockchain developers! Learn more

How to install and run a Geth node

September 12, 2022

What is an Ethereum node or client?

Ethereum nodes are computers participating in Ethereum blockchain network. These nodes are actual computers running software that verifies, stores, and sometimes creates blocks. The actual software is called a "client," and it allows us to interact with the blockchain using the JSON-RPC API, parse and verify the blockchain, and read or write to smart-contracts.

Ethereum is reaching far more developers than ever. With this growth adoption of Ethereum, there has been a flow of multiple Ethereum clients in the industry. Nethermind, Aleth, Geth, and Trinity are the official libraries written and maintained by the Ethereum foundation. Meanwhile, Parity (now known as OpenEthereum) and Hyperledger Besu are two of the most popular third-party clients.

Geth is the most popular Ethereum client out today. It is aimed to be the fastest, lightest, and most secure Ethereum Client. It's written in the Go programming language and maintained by a group of core Ethereum Foundation developers and other contributors. In this article, we will learn how to run a Geth node.

Why use Geth?

There are many reasons you'd use Geth, but our favorite reasons are:

  • Geth is the official client software provided by the Ethereum foundation.
  • Comes with a JavaScript console (run it with `geth console`).
  • Has an interoperable JavaScript client (web3js).
  • Built-in access to the Rinkeby test net (or build your own private Ethereum network).
  • It is generally considered to be the reference implementation for other Ethereum nodes.

Disk space and hardware/computational requirements

Running an Ethereum mainnet node requires a lot of computational resources because downloading the blockchain and validating the blocks requires a lot of CPU and Disk resources.

To run a full node, our basic recommended hardware specs include a multi-core CPU, at least 8GB RAM, and an SSD drive with at least 500GB of free space mounted locally. Plus, a good internet connection is always an uncompromisable factor.

Note: You can use a mounted drive, but may suffer strange performance issues such as dropped blocks or slow syncing.

Node performance can be improved by using caching features, by telling Geth to access the state from memory instead of from your disk, specify the `--cache` flag. This will require you to have additional RAM storage equivalent to the state size of the blockchain, which is over 8GB. This means you should upgrade to 16GB or even 32GB of RAM.

Storage requirement keeps on increasing everyday as the blockchain increases, the most expensive storage requirement at the time when this guide was written is to run a n archive node with Fat DB enabled which is more than 4TB.

Installing Geth

We can install Geth in many ways and on many types of systems; here are a few quick starts for standard methods:

Installing Using a Package Manager

macOS
On macOS, Geth can be installed very easily by using go-ethereum's Homebrew tap:

installing geth

Copy
$ brew tap ethereum/ethereum
$ brew install ethereum

to install master branch use --devel parameter:

installing geth

Copy
$ brew install ethereum --devel

The abigen, bootnode, checkpoint-admin, clef, devp2p, ethkey, evm, faucet, geth, p2psim, puppeth, rlpdump, and wnode commands are then available on your system in /usr/local/bin/.
To find different commands, use:

installing geth

Copy
$ geth --help.

Linux/Ubuntu

Built-in launchpad PPA(Personal Package Manager) is the easiest way to install go-ethereum on Ubuntu-based systems, trusty, xenial, zesty, and artful are the supported Ubuntu versions.
 
To enable go-ethereum's launchpad repository run: 

installing geth

Copy
$ sudo add-apt-repository -y ppa:ethereum/ethereum

Then to install the stable version of go-ethereum:

installing geth

Copy
$ sudo apt-get update
$ sudo apt-get install ethereum

Or to install the develop version:

installing geth

Copy
$ sudo apt-get update
$ sudo apt-get install ethereum-unstable

The abigen, bootnode, clef, evm, geth, puppeth, rlpdump, and wnode commands are then available on your system in /usr/bin/.
To find different commands, use:

installing geth

Copy
$ geth --help.

Windows

The fastest and easiest way to install and run geth on windows is by downloading pre-compiled binaries from here. The page has an installer as well a .zip file; the installer will put geth into your PATH automatically, while the .zip file contains the .exe files, which directly can be run without bothering to run the installer.

Install Geth using Docker

Geth team also maintains four different docker images for running the latest stable or development versions of Geth.

  • ethereum/client-go:latest is the latest development version of Geth
  • ethereum/client-go:stable is the latest stable version of Geth
  • ethereum/client-go:{version} is the stable version of Geth at a specific version number
  • ethereum/client-go:release-{version} is the latest stable version of Geth at a particular version family

To installed Geth client using docker run

installing geth

Copy
$ docker pull ethereum/client-go:latest

$ docker run ethereum/client-go:latest

The image has the following ports automatically exposed:

  • 8545 TCP, used by the HTTP based JSON RPC API
  • 8546 TCP, used by the WebSocket based JSON RPC API
  • 30303 TCP and UDP, used by the P2P protocol running the network
  • 30304 UDP, used by the P2P protocol's new peer discovery overlay

Note: if you are running an Ethereum client inside a docker container, you might want to mount in a data volume as the client’s data directory (located at /root/.ethereum inside the container) to ensure that downloaded data is preserved between restarts and/or container life-cycles.

Suggested flag configuration

After lots of trials and tribulations, we've found a config that works well that we're willing to share. We have some additional flag explanation in the next section, but this is the set of flags that have helped us serve billions of requests per month on a limited number of machines:

suggested flag configuration

Copy
$ geth --http.api eth,web3,net,txpool --ws --ws.api eth,web3,net,txpool

> Note: After The Merge, both execution and consensus clients must be run together in order to run a node. This will require you to enable the  --authrpc.jwtsecret flag and pass in the path to your JWT secret.

Additional flag configuration

The following are some flag configurations for geth:

  • For seeing all other flags and general help:

additional flag configuration

Copy
$ geth --help

  • To enable the HTTP server

additional flag configuration

Copy
$ geth --http

  • To configure the location of the data directory

additional flag configuration

Copy
--datadir={pathtodirectory}

  • To enable mining

additional flag configuration

Copy
--mine 

  • To enable the WS-RPC server.

additional flag configuration

Copy
--ws 

  • To treat accounts as local (comma-separated accounts as value)

additional flag configuration

Copy
--txpool.locals value    

  • To set a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap) (default: 1)

additional flag configuration

Copy
--rpc.txfeecap value 

  • To set a cap on gas that can be used in eth_call/estimateGas (0=infinite) (default: 50000000)

additional flag configuration

Copy
--rpc.gascap value

  • To set the number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain) (default: 2350000)

additional flag configuration

Copy
--txlookuplimit value    

  • If there is no local wallet activity, we can disable the txpool journal:

additional flag configuration

Copy
--txpool.journal ""        # Disk journal for local transaction to survive node restarts (default: "transactions.rlp")

  • If there is sufficient available memory, increasing the cache can speed up the sync

additional flag configuration

Copy
--cache 2048               # Megabytes of memory allocated to internal caching (default: 1024)

  • To unlock accounts (comma separated accounts as value)

additional flag configuration

Copy
--unlock value 

  • To disable the IPC-RPC server.

additional flag configuration

Copy
--ipcdisable

  • To setup Blockchain sync mode ("fast", "full", or "light") (default: fast)

additional flag configuration

Copy
--syncmode value

  • To enable metrics collection and reporting.

additional flag configuration

Copy
--metrics

  • Other things that can be bumped up for performance:

additional flag configuration

Copy
--txpool.accountslots 32   # Minimum number of executable transaction slots guaranteed per account (default: 16)
--txpool.globalslots 8192  # Maximum number of executable transaction slots for all accounts (default: 4096)
--txpool.accountqueue 128  # Maximum number of non-executable transaction slots permitted per account (default: 64)
--txpool.globalqueue 2048  # Maximum number of non-executable transaction slots for all accounts (default: 1024)


Find out more flag configuration and commands here.

Conclusion

Running a node helps make the Ethereum network more resilient. More individual nodes, better decentralization. We at QuickNode run nodes for hundreds of our customers. Let us know if you face any problems while running through the steps in this tutorial. We are always eager to help!!

You can always skip this whole process by getting a QuickNode geth node with us.

Subscribe to our newsletter for more articles and guide on Ethereum. If you have any feedback, please feel free to reach out to us via Twitter, and you can always chat with us if you have a question via our community server on Discord, thanks :)

Related articles 11

Ethereum Full Node vs Archive Node
Published: Apr 8, 2021
Updated: Sep 20, 2022

Ethereum runs on a network of computers (also known as nodes) that verify transactions based on a consensus protocol and ledger, which make up the blockchain. In this guide, you will learn...

Continue reading
How to setup a Chainlink node
Published: Jul 6, 2020
Updated: Sep 21, 2022

Smart-contracts are the heart and soul of all the development happening on the Ethereum blockchain, and as more and more people develop on Ethereum, smart contracts are becoming more...

Continue reading
Introduction to Ethereum Rollups
Published: Dec 28, 2021
Updated: Sep 9, 2022

Ethereum, the most popular blockchain, has seen scaling issues for quite a long time now. With high gas fees due to congestion being the primary pain point. With the increasing cost to use the...

Continue reading
How to run a Hyperledger Besu node
Published: May 18, 2021
Updated: Sep 9, 2022

As the Ethereum network continues to grow, the need for an enterprise-ready Ethereum client arises. Hyperledger Besu is an enterprise-friendly Ethereum client that can implement both public...

Continue reading
How to Run a Binance Smart Chain Node
Published: Jul 2, 2021
Updated: Oct 11, 2022

Binance Smart Chain, BSC for short, is a blockchain that seeks to provide both an alternative and extension to the Ethereum Blockchain. It has done this through several clever implementations...

Continue reading
How to run Nethermind node
Published: May 18, 2021
Updated: Nov 18, 2022

To run an Ethereum node without any problems, it is essential to choose a good node client. Nethermind is one of the oldest and most trusted Ethereum node clients. In this guide, let’s see how...

Continue reading
How to Install and Run a Stacks Node
Published: Aug 26, 2022
Updated: Sep 9, 2022

Stacks 2.0 is an open-source layer-1 blockchain that allows developers to build smart contracts and decentralized blockchain applications. This guide will demonstrate how to install the Stacks...

Continue reading
How to Use Laika with QuickNode
Published: Apr 22, 2022
Updated: Sep 9, 2022

Developers spend most of their time writing code, testing, and fixing bugs. A lot of the time spent with these tasks can be simplified by using a tool like Laika. Laika is a Web3 development...

Continue reading