Test Network Speed with iPerf3 on VPS
iPerf3 is the industry-standard tool for measuring TCP/UDP bandwidth between two endpoints. Unlike downloading test files, iPerf3 measures real network throughput, not web server performance. Use it to verify that your VPS delivers the bandwidth promised, or to debug network bottleneck issues.
Install iPerf3
# Ubuntu/Debian (both server and client)
sudo apt install iperf3 -y
# CentOS/RHEL
sudo yum install iperf3 -y
# macOS
brew install iperf3
# Verify installation
iperf3 --version
Run Server Mode on VPS
# Run iPerf3 in server mode (port 5201 by default)
iperf3 -s
# Run in background and listen on a different port
iperf3 -s -p 5201 -D
# Open firewall
sudo ufw allow 5201/tcp
Test from Client
# Test TCP bandwidth for 10 seconds
iperf3 -c VPS_IP
# Test with multiple threads (measure max throughput)
iperf3 -c VPS_IP -P 4
# Run test longer (60 seconds)
iperf3 -c VPS_IP -t 60
# Test bidirectional (both directions)
iperf3 -c VPS_IP --bidir
# Test UDP (measure latency/jitter)
iperf3 -c VPS_IP -u -b 100M
Read the Results
# Sample TCP test output:
[ ID] Interval Transfer Bitrate
[ 5] 0.00-10.00 sec 1.25 GBytes 1.07 Gbits/sec sender
[ 5] 0.00-10.00 sec 1.25 GBytes 1.07 Gbits/sec receiver
# Transfer = amount of data sent
# Bitrate = bandwidth (1.07 Gbps = good)
# Sample UDP test output:
# Jitter = variation in latency (lower = better for video/VoIP)
# Lost = lost packets (0% = good)
Test Between Two VPS
# VPS A (server): iperf3 -s
# VPS B (client): iperf3 -c VPS_A_IP
# Use this to test network between datacenters
# For example: TH VPS ↔ SG VPS latency and bandwidth
Public iPerf3 Servers for Testing
# No second client? Use public servers for testing
# Check latency from Thailand VPS to Singapore:
iperf3 -c bouygues.testdebit.info -p 5209
# Or use:
ping -c 10 sg.speedtest.xtom.com
iperf3 -c sg.speedtest.xtom.com -p 5201
Verify iPerf3 is Working Correctly
# Check if port is open
ss -tlnp | grep 5201
# Test loopback (should get ~10 Gbps+ on local)
iperf3 -c 127.0.0.1
# Verify firewall allows the port
sudo ufw status | grep 5201
# View process
pgrep -l iperf3
iperf3 -c VPS_IP -J | python3 -c "import sys,json; r=json.load(sys.stdin); print(r['end']['sum_received']['bits_per_second']/1e6, 'Mbps')"
Common Issues & Troubleshooting
Error: "connect failed: Connection refused"
iPerf3 server is not running, or firewall is blocking port 5201:
ssh ubuntu@VPS_IP "iperf3 -s -D"
sudo ufw allow 5201/tcp
# Test again
Bandwidth lower than expected (1 Gbps plan but only get 100 Mbps)
May be due to TCP window size being too small. Increase with the -w flag:
iperf3 -c VPS_IP -w 4M # Increase TCP window size
iperf3 -c VPS_IP -P 8 # Increase parallel streams
UDP test shows high packet loss
Send rate is higher than real bandwidth. Reduce the rate:
# Reduce from 100M to 50M
iperf3 -c VPS_IP -u -b 50M
iPerf3 server stops after a single test
Default behavior accepts 1 connection then stops. Use --daemon or loop:
# Run continuously
iperf3 -s --daemon
# Or run in loop
while true; do iperf3 -s; done
Frequently Asked Questions
How does iPerf3 differ from speedtest-cli?
speedtest-cli measures bandwidth to speedtest.net servers, which may be affected by CDN routing. iPerf3 measures raw network throughput directly between two endpoints, providing more accurate results for VPS-to-VPS or VPS-to-client benchmarks.
Do I need root to run iPerf3?
Not required. Regular users can run iPerf3, except when binding to ports below 1024 or setting QoS/TOS bits, which require CAP_NET_ADMIN capability.
Can I measure latency with iPerf3?
Not directly. iPerf3 measures bandwidth and throughput. Use ping or mtr for latency measurement. iPerf3 UDP mode shows jitter, which is related to latency variation but not absolute latency.