Connect to a running Geth node over HTTP, WebSocket, or IPC using the JSON-RPC API.
Geth implements the Ethereum JSON-RPC specification and exposes additional management APIs. Clients communicate with the node by sending JSON-encoded requests and receiving JSON-encoded responses.
Never expose the HTTP server on a public interface without restricting
--http.api. The admin, debug, and miner namespaces
grant significant control over the node.
WebSocket is a persistent, bidirectional transport. It is required for
event subscriptions via eth_subscribe.
geth --ws --ws.port 8546 --ws.api eth,net,web3
Additional flags:
Flag
Description
--ws.addr
Interface to listen on (default 127.0.0.1)
--ws.port
Port to listen on (default 8546)
--ws.api
Comma-separated list of API namespaces to expose
--ws.origins
Comma-separated list of allowed WebSocket origins
IPC (Inter-Process Communication) uses a Unix domain socket on Linux/macOS
and a named pipe on Windows. It is enabled by default and provides access
to all API namespaces without network exposure.Default socket location:
~/.ethereum/geth.ipc
To change the path:
geth --ipcpath /tmp/geth.ipc
To disable IPC:
geth --ipcdisable
IPC is the safest transport for local tooling and scripts because it is
not accessible over the network.
Geth groups its methods into namespaces. Each namespace must be listed in the
--http.api, --ws.api, or --authrpc.api flags to be accessible over the
corresponding transport. All namespaces are always available over IPC.
The Engine API is a separate authenticated endpoint used by the consensus layer
client (e.g. Prysm, Lighthouse) to drive block production after the Merge.Enable it with a JWT secret file:
All requests to the Engine API must include a Authorization: Bearer <token>
header. The token is a signed JWT that uses the HS256 algorithm with the shared
secret and must contain an iat (issued-at) claim within 60 seconds of the
current time.
Both Geth and your consensus client must be configured with the same JWT
secret file. Mismatched secrets are the most common cause of Geth failing to
follow the chain head after the Merge.
WebSocket connections support eth_subscribe, which pushes events to the
client as they occur rather than requiring polling.
// Subscribe to new block headers{"jsonrpc":"2.0","id":1,"method":"eth_subscribe","params":["newHeads"]}// Subscribe to logs matching a filter{"jsonrpc":"2.0","id":2,"method":"eth_subscribe","params":["logs",{"address":"0xContractAddress","topics":[]}]}// Subscribe to new pending transactions (hash only){"jsonrpc":"2.0","id":3,"method":"eth_subscribe","params":["newPendingTransactions"]}