ab is erroring out with apr_socket_recv: Connection refused (61)

后端 未结 5 1837
一生所求
一生所求 2020-12-23 18:56

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 $>         


        
相关标签:
5条回答
  • 2020-12-23 19:04

    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 讨论(0)
  • 2020-12-23 19:19

    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 讨论(0)
  • 2020-12-23 19:21

    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

    0 讨论(0)
  • 2020-12-23 19:21

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

    0 讨论(0)
  • 2020-12-23 19:25

    New version's apache have fix the issue. Only have to rebuild ab.

    Try to download latest package from http://archive.apache.org/dist/

    Have to patch apache and build a new ab.

    $ wget http://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
    

    Only have to build ab, which located in support folder.

    $ cd support
    $ make
    ...
    $ ./ab -n 10 -c 1 http://localhost:8090/
    

    If your apache is very old, then patch it and build as above.

    $ wget https://www.rtfm.ro/download/patches/ab.patch --no-check-certificate
    $ patch -p0 < ./ab.patch
    

    Done.

    0 讨论(0)
提交回复
热议问题