I updated my MacBook Pro 13" to Lion a few weeks ago. I just found out that Apache Bench (apache2.2.19) is not working. It always shows this error, no matter what:

apr_socket_recv: Connection reset by peer (54)

I also did a clean install on my Mac Mini and it produced the same error.

How can I fix this?

link|improve this question
I too am getting these.. I get them while testing a small Go web server, and with a Python Gevent server. – Justin Sep 30 '11 at 6:15
feedback

3 Answers

This is due to a bug in the Apache software that's bundled with Lion. A more recent version of Apache (beta) fixes the problem. To fix ab, here are the steps:

  1. Download the latest version of Apache

    $ wget http://apache.mirrors.pair.com//httpd/httpd-2.3.16-beta.tar.bz2
    

If 2.3.16 is not available, go to http://apache.mirrors.pair.com/httpd and get the latest

  1. Install pcre (you need brew for this)

    $ brew install pcre
    
  2. Build Apache

    $ tar xzvf httpd-2.3.16-beta.tar.bz2
    $ cd httpd-2.3.16-beta
    $ ./configure
    $ make
    
  3. Overwrite the existing ab with the newly built one

    $ sudo cp support/ab /usr/sbin
    
link|improve this answer
when I make http I get: Undefined symbols: "_apr_file_link", referenced from: _post_rotate in rotatelogs.o ld: symbol(s) not found collect2: ld returned 1 exit status make[2]: *** [rotatelogs] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all-recursive] Error 1 Any tips how to solve that? – Jonathan Jan 20 at 4:04
feedback

Note that if you use -r with Apache Bench, it won't exit on errors.

From the documentation:

-r
Don't exit on socket receive errors.

link|improve this answer
feedback

A few things to test:

  • can you try disabling the firewall any seeing if that works?
  • enable web sharing and test localhost/ (make sure it works in a browser first)

If neither of those work can you open a terminal and

$ sudo opensnoop

then run the apache bench and post the output of the opensnoop terminal in the question. If none of that works you could try installing macports and then installing apache from there and seeing if that works as a work around(sort of lame).

My Air is on lion but the apache version is different(there was an update recently, have you already installed that?). I was able to verify ab does work for me:

$ ab -V
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/
$ uname -a
Darwin air.local 11.1.0 Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64 x86_64
$ ab google.com/ 
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 google.com (be patient).....done


Server Software:        gws
Server Hostname:        google.com
Server Port:            80

Document Path:          /
Document Length:        219 bytes

Concurrency Level:      1
Time taken for tests:   4.130 seconds
Complete requests:      1
Failed requests:        0
Write errors:           0
Non-2xx responses:      1
Total transferred:      511 bytes
HTML transferred:       219 bytes
Requests per second:    0.24 [#/sec] (mean)
Time per request:       4130.343 [ms] (mean)
Time per request:       4130.343 [ms] (mean, across all concurrent requests)
Transfer rate:          0.12 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:     4119 4119   0.0   4119    4119
Processing:    11   11   0.0     11      11
Waiting:       11   11   0.0     11      11
Total:       4130 4130   0.0   4130    4130
link|improve this answer
Thanks for the reply @polynomial :) ab google.com/ works for me too, try ab -n 1000 -c 1000 google.com/ – ben Aug 31 '11 at 7:35
feedback

Your Answer

 
or
required, but never shown

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