Skip to main content

Network RPC Methods

Network RPCs provide information about network status, peer connections, and allow management of network settings.

Network Information

getnetworkinfo

Returns information about the node’s network state.
bitcoin-cli getnetworkinfo
version
number
Bitcoin Core version number
subversion
string
User agent string
protocolversion
number
Protocol version
localservices
string
Services offered by this node (hex)
localservicesnames
array
Human-readable service names
localrelay
boolean
Whether transaction relay is enabled
timeoffset
number
Time offset in seconds
connections
number
Total number of connections
connections_in
number
Number of inbound connections
connections_out
number
Number of outbound connections
networkactive
boolean
Whether p2p networking is enabled
networks
array
Information per network (ipv4, ipv6, onion, i2p, cjdns)
relayfee
number
Minimum relay fee for transactions
incrementalfee
number
Minimum fee increment for mempool replacement
localaddresses
array
List of local addresses
warnings
string
Network warnings

Peer Management

getpeerinfo

Returns data about each connected network peer.
bitcoin-cli getpeerinfo
Returns array of peer objects with detailed information:
id
number
Peer index
addr
string
IP address and port of the peer
addrbind
string
Bind address of the connection to the peer
addrlocal
string
Local address as reported by the peer
network
string
Network type: ipv4, ipv6, onion, i2p, cjdns, not_publicly_routable
services
string
Services offered by peer (hex)
servicesnames
array
Human-readable service names
relaytxes
boolean
Whether we relay transactions to this peer
lastsend
number
Unix timestamp of last send
lastrecv
number
Unix timestamp of last receive
last_transaction
number
Unix timestamp of last valid transaction received
last_block
number
Unix timestamp of last block received
bytessent
number
Total bytes sent
bytesrecv
number
Total bytes received
conntime
number
Unix timestamp of connection time
pingtime
number
Last ping time in seconds
minping
number
Minimum observed ping time in seconds
version
number
Peer version
subver
string
Peer user agent string
inbound
boolean
True for inbound connections, false for outbound
synced_headers
number
Last header we have in common with peer
synced_blocks
number
Last block we have in common with peer
connection_type
string
Connection type: outbound-full-relay, block-relay-only, inbound, manual, addr-fetch, feeler
transport_protocol_type
string
Transport protocol: detecting, v1, v2 (BIP324 encrypted)
session_id
string
Session ID for v2 transport (empty for v1)

getconnectioncount

Returns the number of connections to other nodes.
bitcoin-cli getconnectioncount
result
number
Total number of connections

ping

Requests a ping be sent to all other nodes.
bitcoin-cli ping
Results are provided in getpeerinfo. The ping command measures processing backlog, not just network ping.

addnode

Adds, removes, or tries a connection to a node.
# Add a node
bitcoin-cli addnode "192.168.0.6:8333" "add"

# Remove a node
bitcoin-cli addnode "192.168.0.6:8333" "remove"

# Try connecting to a node once
bitcoin-cli addnode "192.168.0.6:8333" "onetry"

disconnectnode

Disconnects from a specified node.
# Disconnect by address
bitcoin-cli disconnectnode "192.168.0.6:8333"

# Disconnect by node ID
bitcoin-cli disconnectnode "" 1
Provide either address or nodeid, not both.

getaddednodeinfo

Returns information about manually added nodes.
# Get info about all added nodes
bitcoin-cli getaddednodeinfo

# Get info about specific node
bitcoin-cli getaddednodeinfo "192.168.0.6:8333"
addednode
string
Node address
connected
boolean
Whether currently connected
addresses
array
Connection addresses and connection status

getnodeaddresses

Returns known addresses from the node’s address manager.
# Get 10 random addresses
bitcoin-cli getnodeaddresses 10

# Get 5 IPv4 addresses
bitcoin-cli getnodeaddresses 5 "ipv4"
time
number
Unix timestamp when address was last seen
services
number
Services offered by node
address
string
Network address
port
number
Network port
network
string
Network type

Network Control

setnetworkactive

Enables or disables all P2P network activity.
# Disable networking
bitcoin-cli setnetworkactive false

# Enable networking
bitcoin-cli setnetworkactive true
result
boolean
Current network state after command
Disabling network activity will disconnect all peers. Re-enabling will not automatically reconnect to previous peers.

Ban Management

listbanned

Lists all manually banned IP addresses/subnets.
bitcoin-cli listbanned
address
string
Banned IP/subnet
ban_created
number
Unix timestamp when ban was created
banned_until
number
Unix timestamp when ban expires

setban

Adds or removes an IP/subnet from the banned list.
# Ban IP for 24 hours (default)
bitcoin-cli setban "192.168.0.6" "add"

# Ban subnet for 1 hour
bitcoin-cli setban "192.168.0.0/24" "add" 3600

# Remove ban
bitcoin-cli setban "192.168.0.6" "remove"

clearbanned

Clears all banned IPs.
bitcoin-cli clearbanned

Traffic Control

getnettotals

Returns information about network traffic, including bytes received and sent.
bitcoin-cli getnettotals
totalbytesrecv
number
Total bytes received
totalbytessent
number
Total bytes sent
timemillis
number
Current Unix time in milliseconds
uploadtarget
object
Upload target information:
  • timeframe: Target timeframe in seconds
  • target: Target in bytes (0 = no limit)
  • target_reached: Whether target was reached
  • serve_historical_blocks: Whether serving historical blocks
  • bytes_left_in_cycle: Bytes left in current cycle
  • time_left_in_cycle: Seconds left in current cycle

Connection Types

Bitcoin Core maintains different types of connections:

Transport Protocols

Network Types

Bitcoin Core supports multiple network types:
  • ipv4: IPv4 connections
  • ipv6: IPv6 connections
  • onion: Tor hidden service connections
  • i2p: I2P (Invisible Internet Project) connections
  • cjdns: CJDNS network connections
  • not_publicly_routable: Internal/private network connections