Skip to content

Geth_setup

Chapter 7: Geth Client - Setup & Configuration

Section titled “Chapter 7: Geth Client - Setup & Configuration”

Geth (Go Ethereum) is the most popular and widely-used Ethereum client. It’s written in Go and developed by the Ethereum Foundation. Understanding Geth is essential for any blockchain infrastructure engineer.


RequirementMinimumRecommended
OSUbuntu 20.04+, macOS, WindowsUbuntu 22.04 LTS
CPU4 cores8+ cores
RAM8 GB16-32 GB
Storage1 TB SSD2 TB NVMe SSD
Network25 Mbps100 Mbps
Section titled “Method 1: Download Binary (Recommended for Quick Start)”
Terminal window
# Download latest Geth
cd /tmp
wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.13.14-8ab7ff97.tar.gz
tar -xzf geth-linux-amd64-1.13.14-8ab7ff97.tar.gz
sudo mv geth-linux-amd64-1.13.14-8ab7ff97/geth /usr/local/bin/
rm -rf geth-linux-amd64-1.13.14-8ab7ff97*
# Verify installation
geth version
Terminal window
# Install Go (if not installed)
wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
# Clone and build Geth
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum
make geth
sudo cp build/bin/geth /usr/local/bin/
Terminal window
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install geth

Terminal window
# Start Geth with default settings (connects to mainnet)
geth
# Start with console attached
geth console
# Check Geth version
geth version

Expected output:

Geth
Version: 1.13.14-8ab7ff97
Architecture: amd64
Protocol Versions: [68]
Network Protocols:
Ethereum: 68
Go Version: go1.21.5
Operating System: linux
GOPATH=
GOROOT=/usr/local/go

Terminal window
geth \
--syncmode full \
--http \
--http.addr 0.0.0.0 \
--http.port 8545 \
--http.api eth,net,web3,debug,txpool \
--http.corsdomain "*" \
--ws \
--ws.addr 0.0.0.0 \
--ws.port 8546 \
--ws.api eth,net,web3 \
--ws.origins "*" \
--datadir /data/ethereum \
--port 30303 \
--maxpeers 50
FlagDescriptionExample
--syncmodeSynchronization modefull, snap, light
--httpEnable HTTP-RPC server
--http.addrHTTP server bind address0.0.0.0 (all interfaces)
--http.portHTTP server port8545
--http.apiEnabled HTTP APIseth,net,web3
--wsEnable WebSocket server
--ws.portWebSocket port8546
--datadirData directory path/data/ethereum
--portP2P networking port30303
--maxpeersMaximum peer connections50

Geth supports multiple synchronization modes:

┌─────────────────────────────────────────────────────────────────────────────┐
│ GETH SYNC MODES │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ │
│ │ FULL SYNC │ ◄── Downloads and verifies every block │
│ │ │ Most secure, slowest initial sync │
│ └────────┬────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ SNAP SYNC │ ◄── Downloads latest state, fastest │
│ │ (Default) │ Recommended for most users │
│ └────────┬────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ LIGHT CLIENT │ ◄── Only block headers + minimal data │
│ │ │ Fastest, limited functionality │
│ └─────────────────┘ │
│ │
│ Recommendation: Use --syncmode snap for production nodes │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
ModeInitial SyncStorageFunctionalitySecurity
FullDays~1.2 TBCompleteHighest
SnapHours~1.2 TBCompleteHigh
LightMinutes~1 GBLimitedMedium

Terminal window
geth \
--syncmode snap \
--http \
--http.addr 127.0.0.1 \
--http.port 8545 \
--http.api eth,net,web3,debug,txpool,erigon \
--http.vhosts "*" \
--ws \
--ws.addr 127.0.0.1 \
--ws.port 8546 \
--ws.api eth,net,web3,debug,txpool,erigon \
--ws.origins "*" \
--datadir /data/ethereum \
--port 30303 \
--maxpeers 100 \
--cache 4096 \
--gc 1 \
--txpool.globalslots 4096 \
--txpool.globalqueue 1024 \
--metrics \
--metrics.addr 0.0.0.0 \
--metrics.port 6060 \
--pprof \
--pprof.addr 0.0.0.0 \
--pprof.port 6061
ParameterDescriptionRecommended
--cacheMemory for caching (MB)4096 (4GB)
--gcEnable garbage collection1
--txpool.globalslotsMax pending transactions4096
--txpool.globalqueueMax queued transactions1024
--metricsEnable Prometheus metrics
--pprofEnable profiling API

Terminal window
sudo nano /etc/systemd/system/geth.service
[Unit]
Description=Ethereum Geth Node
After=network.target
Wants=network-online.target
[Service]
Type=simple
User=ethereum
Group=ethereum
Restart=always
RestartSec=10
ExecStart=/usr/local/bin/geth \
--syncmode snap \
--http \
--http.addr 127.0.0.1 \
--http.port 8545 \
--http.api eth,net,web3,debug,txpool \
--ws \
--ws.addr 127.0.0.1 \
--ws.port 8546 \
--ws.api eth,net,web3 \
--datadir /data/ethereum \
--port 30303 \
--maxpeers 100 \
--cache 4096 \
--metrics \
--pprof
# Hardening
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/data/ethereum
[Install]
WantedBy=multi-user.target
Terminal window
# Reload systemd
sudo systemctl daemon-reload
# Create user and directories
sudo useradd -r -s /sbin/nologin ethereum
sudo mkdir -p /data/ethereum
sudo chown ethereum:ethereum /data/ethereum
# Enable and start
sudo systemctl enable geth
sudo systemctl start geth
# Check status
sudo systemctl status geth
sudo journalctl -fu geth -n 100

Terminal window
# Pull Geth image
docker pull ethereum/client-go:latest
# Run Geth container
docker run -d \
--name ethereum-node \
-p 30303:30303 \
-p 8545:8545 \
-p 8546:8546 \
-v /data/ethereum:/data \
ethereum/client-go:latest \
--syncmode snap \
--http \
--http.api eth,net,web3 \
--datadir /data
version: '3.8'
services:
geth:
image: ethereum/client-go:latest
container_name: geth-node
ports:
- "30303:30303"
- "8545:8545"
- "8546:8546"
volumes:
- ./data:/data
environment:
- SYNCMODE=snap
command:
- --syncmode=snap
- --http
- --http.api=eth,net,web3
- --datadir=/data
restart: unless-stopped

Terminal window
geth \
--sepolia \
--syncmode snap \
--http \
--http.addr 127.0.0.1 \
--http.port 8545 \
--datadir /data/ethereum-sepolia
Terminal window
geth \
--goerli \
--syncmode snap \
--http \
--http.addr 127.0.0.1 \
--http.port 8545 \
--datadir /data/ethereum-goerli
Terminal window
geth \
--holesky \
--syncmode snap \
--http \
--http.addr 127.0.0.1 \
--http.port 8545 \
--datadir /data/ethereum-holesky

Terminal window
geth attach http://localhost:8545
# Check sync status
eth.syncing
# Example output:
{
currentBlock: 18500000,
highestBlock: 18501234,
knownStates: 123456,
pulledStates: 120000,
startingBlock: 18499000
}
# If false, node is synced
eth.syncing
# false
Terminal window
# Check block number
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
# Check syncing status
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'

QuestionAnswer
How to check if Geth is synced?Use eth.syncing in console - returns false when synced
Difference between sync modes?Full = verify all; Snap = download state; Light = headers only
What port does Geth use?30303 for P2P, 8545 for HTTP, 8546 for WebSocket
How to make node production-ready?Use systemd, proper flags, monitoring

  • Geth is the Go implementation of Ethereum
  • Install via binary, source, or package manager
  • Use --syncmode snap for fastest sync
  • Configure HTTP/WebSocket APIs for dApp access
  • Use systemd for production deployment
  • Monitor sync status via RPC or console

In Chapter 8: Geth CLI Options & Flags, we’ll explore all Geth command-line options in detail.


Last Updated: 2026-02-20