85

I am testing eventlet out, and I am getting this error:

~>ab -n 10 -c 1 http://localhost:8090/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)...apr_socket_recv: Connection reset by peer (54)
Total of 2 requests completed

The website works at localhost:8090/ and returns 200 OK.

I had the same issue with tomcat, again the website worked fine.

What could the issue be?

3
  • 1
    Could this be an ipv6 problem, ab trying to translate localhost and use ::1 first and failing? Commented Nov 14, 2011 at 11:49
  • Could this be a firewall problem? Or maybe you are using proxy?
    – utapyngo
    Commented Nov 19, 2011 at 13:35
  • 1
    If you get this error when ab has made ~16k requests, on macOS, see this: stackoverflow.com/a/30357879/537554 for an explanation, and serverfault.com/a/145937/91715 for a fix.
    – ryenus
    Commented Jul 14, 2019 at 16:44

5 Answers 5

182

I found using 127.0.0.1 rather than localhost worked:

ab -n 10 -c 1 http://127.0.0.1:8090/

Update: May have been a bug in ab: https://groups.google.com/forum/#!msg/nodejs/TZU5H7MdoII/yivu0d4LMaAJ

4
  • 3
    hi, not for me, I get the same error. Are you running lion? it worked fine for me b4 upgrading.
    – Blankman
    Commented Nov 14, 2011 at 0:16
  • 2
    My error was slightly different to you - but yes I'm on Lion. Looks like an ab bug on Lion: groups.google.com/forum/#!msg/nodejs/TZU5H7MdoII/yivu0d4LMaAJ
    – dkam
    Commented Nov 15, 2011 at 10:13
  • Same goes for Mountain Lion, it has version 2.3 of ab.
    – Arne
    Commented Dec 31, 2012 at 13:04
  • my be reduce the concurrency parameter which worked for me
    – Deepak
    Commented May 26, 2017 at 7:16
12

add the -r option which means Don't exit on socket receive errors. At times you might change the default ulimit size value. ab -r -n 10 -c 1 http://localhost:8090/

0
11

New versions of Apache have fixed the issue. Download the latest package from https://archive.apache.org/dist/:

$ wget https://archive.apache.org/dist/httpd/httpd-2.3.16-beta.tar.bz2
$ tar jxvf httpd-2.3.16-beta.tar.bz2 
$ cd httpd-2.3.16-beta
$ ./configure

You only have to build ab, which is located in the support folder.

$ cd support
$ make
...
$ ./ab -n 10 -c 1 http://localhost:8090/
3
  • Make sure to cp support/ab to /usr/sbin (or wherever as determined by 'which ab' Commented May 20, 2012 at 7:15
  • This links to a page for RTFM; frankly the user that added that link, should be banned
    – MrMesees
    Commented Dec 21, 2023 at 15:25
  • @MrMesees: It’s just a dead link that used to be a patch file back in 2012 when this answer was written.
    – Ry-
    Commented Dec 22, 2023 at 3:18
1

Another related bug that is still present in ab (apache-2.4.29) is that it takes just the first result from getaddrinfo. It's probably this bug that is mentioned by Jürgen Strobel in a comment. Let's say you have /etc/hosts that goes like this:

127.0.0.1   localhost.localdomain   localhost
::1     localhost.localdomain   localhost

The first result returned by getaddrinfo for localhost is ::1. So ab tries to connect over IPv6 and fails. The workaround is to use 127.0.0.1: ab -n 10 127.0.0.1/. Or reorder the lines. Though, in my case it says:

Benchmarking localhost (be patient)...apr_socket_recv: Connection refused (111)
0

There is a patch for this bug, I followed the steps of this guide and it seems to work for me now in Lion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.