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. matlab 高级函数 —— colfilt/blockproc (图像)矩阵的分块处理

    colfilt 执行功能与 blockproc/nlfilter 类似,但效率更高. B = colfilt(A,[m n],block_type,fun),block_type:distinct/s ...

  2. 五笔字根--good

    https://gss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/4b90f603738da977b1b5ce57b251f8198 ...

  3. Mint UI 使用指南

    上来直接在webpack里将Mint UI引入项目,发现各种问题.饿了么组件库文档太坑了,好多地方写错,有些该说明的地方没说,比如例子里单文件.vue组件里用的类post-css处理器,我一直使用SA ...

  4. 从PHP到Node

    花12天时间,断断续续学了PHP和MySQL.学完PHP基础后,本以为很快就能做个中等项目,发现还是不行,可是是学习PHP的时间太短了吧,需要一定强度的练习,学新框架才行.PHP就先放一下吧,就当通过 ...

  5. matlab 图像的保存

    gcf:获取当前显示图像的句柄: 默认 plot 的 position 是 [232 246 560 420] 0. save >> A = randn(3, 4); >> B ...

  6. Python 金融数据分析 (一)—— 股票数据

    1. tushare 库 tushare 的官网请见:TuShare -财经数据接口包,是国人自己开发的 Python 爬数据工具(所谓的爬,自然就是在线连网获取数据),囊括股票.期货.宏观经济.电影 ...

  7. wpf控件设计时支持(2)

    原文:wpf控件设计时支持(2) 这篇介绍在wpf设计时集合项属性添加项的定义和自定义控件右键菜单的方法 集合项属性设计时支持 1.为集合属性设计器识别具体项类型 wpf设计器允许定义集合项的类型,如 ...

  8. Tagging Physical Resources in a Cloud Computing Environment

    A cloud system may create physical resource tags to store relationships between cloud computing offe ...

  9. Matlab Tricks(十八)—— 矩阵间元素距离的计算

    两个矩阵间元素(向量)距离的度量,首先想到的是遍历,循环的方式,显然 matlab 下的编程并不推荐,matlab 下矩阵向量化编程效率尤高. 先考虑两个向量距离的计算: ∥x−y∥2=∥x∥2+∥y ...

  10. NS2网络模拟(2)-丢包率

    1: #NS2_有线部分\LossRate.awk 2: 3: BEGIN { 4: #Initialize the variable 5: Lost = 0; #the Sum of Lost pa ...