Skip to content

Geth_cli

This chapter provides a comprehensive reference of Geth command-line options. Understanding these flags is essential for configuring and optimizing your Ethereum node.


FlagDescriptionExample
--networkidNetwork identifier--networkid 1 (mainnet)
--syncmodeSync mode: full, snap, light--syncmode snap
--snapEnable snap sync (deprecated, use syncmode)
--light.serveServe light clients--light.serve 100
--light.maxpeersMax light client peers--light.maxpeers 80
NetworkChain IDNetwork ID
Ethereum Mainnet11
Sepolia1115511111155111
Goerli55
Holesky1700017000
Private TestnetCustomCustom

┌─────────────────────────────────────────────────────────────────────────────┐
│ HTTP/RPC CONFIGURATION │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ HTTP SERVER │ │
│ │ │ │
│ │ --http Enable HTTP server │ │
│ │ --http.addr Bind address (default: localhost) │ │
│ │ --http.port Port (default: 8545) │ │
│ │ --http.api Enabled APIs │ │
│ │ --http.vhosts Virtual hostnames (comma-separated) │ │
│ │ --http.corsdomain CORS domains │ │
│ │ --http.ratelimit Rate limit (requests/sec) │ │
│ │ --http.ratelimitburst Rate limit burst │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ WEBSOCKET SERVER │ │
│ │ │ │
│ │ --ws Enable WebSocket server │ │
│ │ --ws.addr Bind address │ │
│ │ --ws.port Port (default: 8546) │ │
│ │ --ws.api Enabled APIs │ │
│ │ --ws.origins Allowed origins │ │
│ │ --ws.ratelimit Rate limit (requests/sec) │ │
│ │ --ws.extradataprefix Extra data prefix │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
NamespaceDescription
ethEthereum API (blocks, transactions, accounts)
netNetwork status
web3Web3 utilities
debugDebugging & tracing APIs
txpoolTransaction pool information
erigonErigon-specific APIs
traceTransaction tracing
Terminal window
geth \
--http \
--http.addr 0.0.0.0 \
--http.port 8545 \
--http.api eth,net,web3,debug,txpool \
--http.vhosts "localhost,yourdomain.com" \
--http.corsdomain "https://your-dapp.com"

FlagDescription
--datadirPath to database and keystore
--keystorePath to keystore (default: datadir/keystore)
--configPath to config file (TOML)
Terminal window
# Database cache settings
--cache 4096 # Memory cache in MB
--database.engine pebbledb # Database engine (leveldb/pebbledb)
# State pruning
--pruneancientstore # Prune ancient data after merge
# State history
--history.state 90000 # Number of state entries to keep
--history.transactions 90000 # Number of tx entries to keep
ModeStorage (Mainnet)
Full (pruned)~1.2 TB
Snap (pruned)~1.2 TB
Archive~12 TB

FlagDescriptionDefault
--portP2P listening port30303
--maxpeersMaximum peer count50
--maxpendpeersMaximum pending connections0
--natNAT traversalany
Terminal window
# Bootnodes
--bootnodes enode://enr:...@bootnode1.example.com:30303
# Static peers
--staticnodes enode://...@peer1.example.com:30303
# Disable discovery (for private networks)
--nodiscover
# V5 discovery
--v5disc

Mainnet:

--bootnodes "enr:-KG4QOtcL ... @bootnode.mainnet.ethdisco.net:30303"

Sepolia:

--bootnodes "enr:-KG4QOtcL ... @bootnode.sepolia.ethdisco.net:30303"

┌─────────────────────────────────────────────────────────────────┐
│ TRANSACTION POOL │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Pending Queue (Global Slots) │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ Default: 4096 slots │ │
│ │ Flag: --txpool.globalslots 4096 │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Queued Transactions (Global Queue) │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ Default: 1024 queue │ │
│ │ Flag: --txpool.globalqueue 1024 │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ Per-Account Limits: │
│ - slots: 16 (default) │
│ - queue: 64 (default) │
│ │
└─────────────────────────────────────────────────────────────────┘
FlagDescriptionDefault
--txpool.localsComma-separated accounts to prioritize
--txpool.nolocalsDisable local account prioritization
--txpool.price LimitMinimum gas price1 Gwei
--txpool.accountqueueMax transactions per account queue64
--txpool.accountslotsMax transactions per account pending16

FlagDescription
--mineEnable mining
--miner.threadsNumber of mining threads
--miner.etherbaseCoinbase address for mining rewards
--miner.extradataExtra data for mined blocks
--miner.gaspriceMinimum gas price for transactions
--miner.gaslimitBlock gas limit
Terminal window
# Set minimum gas price for mining
geth --mine --miner.etherbase 0x... --miner.gasprice 20000000000

FlagDescription
--verbosityLog level (0-6)
--vmodulePer-module log level
--log.jsonJSON logging format
--log.fileLog file path
LevelDescription
0Critical
1Error
2Warning
3Info (default)
4Debug
5Trace
Terminal window
# Set verbosity to debug
--verbosity 4
# Debug only p2p module
--vmodule p2p=4,eth=3
# Log to file
--log.file /var/log/geth.log
# JSON logging
--log.json

Terminal window
# Enable metrics
--metrics
# Enable metrics server
--metrics.addr 0.0.0.0
--metrics.port 6060
# Custom metrics prefix
--metrics.prefix eth
EndpointDescription
/debug/metricsPrometheus metrics
/debug/metrics/prometheusPrometheus format
/debug/pprofpprof UI
Terminal window
# Enable pprof
--pprof
# pprof address
--pprof.addr 0.0.0.0
--pprof.port 6061
Terminal window
# Get heap profile
curl http://localhost:6061/debug/pprof/heap > heap.out
# CPU profile
curl http://localhost:6061/debug/pprof/profile > cpu.out
# View trace
go tool pprof http://localhost:6061/debug/pprof/trace

Create config.toml:

[Eth]
SyncMode = "snap"
NetworkId = 1
[Eth.TxPool]
Locals = ["0x742d35Cc6634C0532925a3b844Bc9e7595f1e3E4"]
NoLocals = false
Journal = "transactions.rlp"
Rejournal = 3600000000000
[Node]
DataDir = "/data/ethereum"
HTTPHost = "0.0.0.0"
HTTPPort = 8545
HTTPVirtualHosts = ["*"]
HTTPModules = ["eth", "net", "web3", "debug", "txpool"]
WSHost = "0.0.0.0"
WSPort = 8546
WSModules = ["eth", "net", "web3", "debug", "txpool"]
P2P = {
MaxPeers = 100,
Port = 30303,
}
[Metrics]
Enabled = true
Addr = "0.0.0.0"
Port = 6060
Terminal window
geth --config /path/to/config.toml

Terminal window
geth \
--config /etc/geth/config.toml \
--syncmode snap \
--http \
--http.addr "0.0.0.0" \
--http.port 8545 \
--http.api "eth,net,web3,debug,txpool" \
--http.vhosts "*" \
--http.corsdomain "*" \
--ws \
--ws.addr "0.0.0.0" \
--ws.port 8546 \
--ws.api "eth,net,web3,debug,txpool" \
--ws.origins "*" \
--datadir /data/ethereum \
--port 30303 \
--maxpeers 100 \
--cache 8192 \
--txpool.globalslots 8192 \
--txpool.globalqueue 2048 \
--metrics \
--metrics.addr "0.0.0.0" \
--metrics.port 6060 \
--pprof \
--pprof.addr "0.0.0.0" \
--pprof.port 6061

QuestionAnswer
What is the default HTTP port?8545
What is the default P2P port?30303
How to enable debug APIs?--http.api eth,net,web3,debug
What does --cache flag do?Sets memory cache in MB

  • Geth has extensive CLI options for all configurations
  • Key areas: HTTP/WS APIs, P2P networking, database, txpool
  • Use TOML config file for complex setups
  • Enable metrics for monitoring

In Chapter 9: Erigon Client - High-Performance Ethereum, we’ll explore alternative Ethereum clients.


Last Updated: 2026-02-20