The following command fails:

$ ab -n 1 localhost:8000/
...
Benchmarking localhost (be patient)...apr_socket_recv: Connection refused (111) But this one succeeds: $ ab -n 1 127.0.0.1:8000/ In /etc/hosts I have: 127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost The issue here is caused by ab taking the first result returned by apr_sockaddr_info_get: https://github.com/apache/httpd/blob/2.4.29/support/ab.c#L1835-L1837 But apr_sockaddr_info_get returns a list. If it were to try the second sockaddr structure, it would connect. This way it works: rv = apr_sockaddr_info_get(&sa, REMOTE_HOST, APR_UNSPEC, REMOTE_PORT, 0, mp);
if (rv != APR_SUCCESS) {
return rv;
} for ( ; sa; sa = sa->next) {
rv = apr_socket_create(&s, sa->family, SOCK_STREAM, APR_PROTO_TCP, mp);
if (rv != APR_SUCCESS) {
return rv;
} apr_socket_opt_set(s, APR_SO_NONBLOCK, 1);
apr_socket_timeout_set(s, SOCK_TIMEOUT); rv = apr_socket_connect(s, sa);
if (rv == ECONNREFUSED) {
continue;
} else if (rv == APR_SUCCESS) {
break;
} else {
return rv;
}
} apr_socket_opt_set(s, APR_SO_NONBLOCK, 0);
apr_socket_timeout_set(s, SOCK_TIMEOUT); Other tools (like, curl, wget, w3m) deal with it just fine. P.S. A couple of links just in case https://gist.github.com/x-yuri/5ad28ac0a22ca19a7c3073ce0de5abf0
https://gist.github.com/x-yuri/95fd4776fb9bf8f1eaae7eb2e7ed6bd4

  

ab fails to connect to localhost的更多相关文章

  1. Docker - Failed to connect to localhost port 4000: Connection refused

    转载.翻译自 https://stackoverflow.com/questions/44014698/docker-failed-to-connect-to-localhost-port-4000- ...

  2. Nodejs学习之mongodb Error: failed to connect to [localhost:27017]

    在连接mongodb时出现以下错误提示信息 events.js: throw er; // Unhandled 'error' event ^ Error: failed to connect to ...

  3. 【Docker】在本地打包maven程序为docker镜像报错: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1]

    错误信息: [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on pr ...

  4. Eureka 注册中心一直报Connect to localhost:8761 time out 的问题

    忽略了配置eureka.client.service-url.defaultZone而导致的异常,重新覆盖配置就好 client: fetch-registry: false register-wit ...

  5. Eureka报错: Connect to localhost:8761 timed out

    最近整理配置Eureka时, 注册服务后, Eureka服务一直报出如下错误: 如下是我的单台eureka的 application.yml 配置: spring: application: name ...

  6. Linux项目部署 jdk tomcat 安装配置 linux下 failed connect to localhost:8080;Connection refused

         ONBOOT=yes 5.安装wget (1)安装 yum -y install wget (2) 查看版本  wget --version或 wget -V 一.安装jdk 配置 (1)安 ...

  7. ab性能并发测试语法

    ab测试语法ab -n 全部请求数 -c 并发数 测试url 例如:ab -n 10000 -c 1000 http://myweb.com/test.html Server Software: Ap ...

  8. Apache ab 压力并发测试工具

    当你使用PHP(或其他编程语言)完成一个web程序的开发,并且web程序在Apache服务器上正常运行的时候,你有没有考虑过对你的Apache服务器及部署在其上的web程序进行一些压力测试呢?毕竟,真 ...

  9. MySQL数据库localhost的root用户登陆遭遇失败

    问题:Access denied for user 'root'@'localhost' (using password: YES)打开MySQL目录下的my.ini文件(Linux的话是/etc/m ...

随机推荐

  1. new与属性访问的顺序,从一道JS面试题说起

    这段时间一直在研究设计模式,在看工厂模式的时候,看到一段代码 VehicleFactory.prototype.createVehicle = function ( options ) { if( o ...

  2. Arcgis api for javascript学习笔记(4.5版本) - 获取FeatureLayer中的graphics集合

    在Arcgis api for javascript 3.x 版本中,我们可以直接通过某个FeatureLayer对象中的graphics属性获取要素集合. graphics属性 但是在4.x版本中, ...

  3. C#后台调用前台js方法

    前台js方法(写在head标签之内) <script type="text/javascript" language="javascript"> f ...

  4. jQuery插件实现的页面功能介绍引导页效果

    新产品上线或是改版升级,我们会在用户第一次使用产品时建立一个使用向导,引导用户如何使用产品,如使用演示的方式逐一介绍界面上的功能模块,从而提升了用户体验和产品的亲和力. Helloweba.com之前 ...

  5. Android UI法宝的发展Android Action Bar Style Generator

    ActionBar它是3.0经UI设计规格.同时它是Google设计风格强烈推荐,如何做一个高速设计的眼睛ActionBar之.进一步,我们设置了阶段为一个入眼ActionBar模板吧,然后,Andr ...

  6. 仿照Android的池化技术

    /** * 仿照Android池化技术 * @author fgtian * */ public class ObjectCacheTest { public static class ObjectI ...

  7. Internet protocol security (ipsec) packet processing for multiple clients sharing a single network address

    Embodiments of the present invention address deficiencies of the art in respect to secure communicat ...

  8. Facebook巴特尔与谷歌移动广告 急于打开中国市场

    随着Facebook(62.5, -0.69, -1.09%)即将设立了销售办事处在北京发酵消息.谷歌(556.33, 2.43, 0.44%)似还差点自觉保护国内市场. 6月5日,谷歌在深圳举行了面 ...

  9. 学习 NLP(一)—— TF-IDF

    TF-IDF(Term Frequency & Inverse Document Frequency),是一种用于信息检索与数据挖掘的常用加权技术.它的主要思想是:如果某个词或短语在一篇文章中 ...

  10. 奥格尔巧妙kfifo

    奥格尔巧妙kfifo Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csdn.net/chen19870707 Date:O ...