Skip to main content

How to Install and Run a Geth Node

Updated on
Nov 16, 2023

6 min read

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:

$ brew tap ethereum/ethereum
$ brew install ethereum

to install master branch use --devel parameter:

$ 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:

$ 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: 

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

Then to install the stable version of go-ethereum:

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

Or to install the develop version:

$ 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:

$ 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

$ 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:

$ 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:
$ geth --help
  • To enable the HTTP server
$ geth --http
  • To configure the location of the data directory
--datadir={pathtodirectory}
  • To enable mining
--mine 
  • To enable the WS-RPC server.
--ws 
  • To treat accounts as local (comma-separated accounts as value)
--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)
--rpc.txfeecap value 
  • To set a cap on gas that can be used in eth_call/estimateGas (0=infinite) (default: 50000000)
--rpc.gascap value
  • To set the number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain) (default: 2350000)
--txlookuplimit value    
  • If there is no local wallet activity, we can disable the txpool journal:
--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
--cache 2048               # Megabytes of memory allocated to internal caching (default: 1024)
  • To unlock accounts (comma separated accounts as value)
--unlock value 
  • To disable the IPC-RPC server.
--ipcdisable
  • To setup Blockchain sync mode ("fast", "full", or "light") (default: fast)
--syncmode value
  • To enable metrics collection and reporting.
--metrics
  • Other things that can be bumped up for performance:
--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 :)

We ❤️ Feedback!

Let us know if you have any feedback or requests for new topics. We'd love to hear from you.

Share this guide