How to Fix “iperf connect failed: Connection refused” Error: Network Testing Guide


7 views

The error iperf -c 192.168.3.2 -i 2
connect failed: Connection refused
typically indicates one of three fundamental problems:

  • The iperf server isn't running on the target machine (192.168.3.2)
  • A firewall is blocking the default port (5201)
  • Network connectivity issues between client and server

First, ensure the iperf server is running on 192.168.3.2 with proper parameters:

# On the server machine (192.168.3.2)
iperf3 -s -p 5201

Common mistakes include:

  • Using wrong version (iperf2 vs iperf3)
  • Not specifying the port when custom port is used
  • Not running as root when using privileged ports (<1024)

On Linux systems, check and modify firewall rules:

# Check firewall status
sudo ufw status

# Allow specific port
sudo ufw allow 5201/tcp

# For CentOS/RHEL:
sudo firewall-cmd --add-port=5201/tcp --permanent
sudo firewall-cmd --reload

When basic checks don't resolve the issue:

# Verify network connectivity
ping 192.168.3.2

# Check port accessibility
nc -zv 192.168.3.2 5201

# Alternative port test
iperf3 -c 192.168.3.2 -p 5202

For enterprise networks with strict policies:

# Server side with custom port
iperf3 -s -p 51000

# Client side with multiple streams
iperf3 -c 192.168.3.2 -p 51000 -P 4 -t 30 -i 5

For Windows environments:

  • Check Windows Defender Firewall rules
  • Ensure iperf3.exe is in PATH or use full path
  • Run command prompt as administrator

When running iperf -c 192.168.3.2 -i 2, the "Connection refused" error typically indicates one of these scenarios:

  • The iperf server isn't running on the target machine (192.168.3.2)
  • The default port (5001) is blocked by firewall
  • Network connectivity issues between client and server

First, ensure the server is properly running on 192.168.3.2:

# On the server machine (192.168.3.2)
iperf -s -p 5001

If you want to use a different port (e.g., 5201):

iperf -s -p 5201

On Linux servers, check firewall rules:

sudo ufw status
sudo iptables -L

To allow iperf port (5001):

sudo ufw allow 5001/tcp
sudo ufw reload

Try connecting with explicit port specification:

iperf -c 192.168.3.2 -p 5201 -i 2

For UDP testing (bypassing some TCP restrictions):

iperf -c 192.168.3.2 -u -p 5001 -i 2

Verify basic connectivity first:

ping 192.168.3.2
telnet 192.168.3.2 5001

Check if the port is actually listening on the server:

netstat -tulnp | grep iperf
ss -tulnp | grep iperf

For persistent issues, run iperf in verbose mode:

iperf -c 192.168.3.2 -p 5001 -i 2 -V

Check system logs for firewall blocks:

journalctl -xe
dmesg | grep DROP