13

iperf -c 192.168.3.2 -i 2
connect failed: Connection refused

3.2 is another machine. I think the port might be blocked.

How can I make this work?

4
  • 9
    This may be a stupid question, but: are you running "iperf -s" on 192.168.3.2?
    – Handyman5
    Jun 16, 2011 at 8:52
  • 2
    Another reason to get this error is running the IPerf server in UDP mode and client in TCP mode and vice versa. Jan 24, 2013 at 14:46
  • 2
    Make sure Server & Client versions are the same... I had the same problem!
    – user301514
    Jul 26, 2015 at 21:28
  • Make sure you are using same version of iperf
    – user348148
    Apr 9, 2016 at 18:12

4 Answers 4

26

You also get a "connection refused" error when you use an iperf v3 client to send to an iperf v2 server.

The message is slightly different though:

iperf3: error - unable to connect to server: Connection refused

As the iperf3 doc states, they are not compatible (at least up to version 3.1.2). You can check the version on both server and client with

iperf -v
2
  • 2
    This is what happened to me. The windows version had the newest one (3.1.3) while for arch installing iperf gave me an old 2.0.5. Installing iperf3 on arch gave me the newest version, after which all went well.
    – hak8or
    Aug 14, 2016 at 19:49
  • Even in 2022 this is so much useful ! Thanks Sep 21, 2022 at 4:45
11

I doubt that this is a firewall issue. Usually, firewalls employ the DROP rule for packets that are not allowed. A "connection refused" means that there is no application listening on the port it tries to connect to. The destination host indicates this with a corresponding ICMP message to the source.

In order to run iperf you must have a server running on the machine which you iperf to. To do this run iperf -s on the server. After that you can then run iperf -c <server IP or hostname> -i 2

After running this you will get an ouput that looks something like this:

------------------------------------------------------------
Client connecting to <server IP>, TCP port 5000
TCP window size:   256 KByte (default)
------------------------------------------------------------
[  3] local 123.123.123.123 port 4000 connected with 123.123.123.123 port 5000
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.1 GBytes  1.09 Gbits/sec
0

You can use the -C command line option to force both ends to use an older version of the protocol and this will prevent the error.

From the help output:

-C, --compatibility      for use with older versions does not sent extra msgs
-1

Try turning off any firewall on the machines. On many linux distros, you can do

service firewall off

to disable the firewall.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .