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 高级函数 —— circshift、squeeze

    circshift:顾名思义,循环移动,循环的意义在于,移出的数据不丢失,而是来到队列的首部位置,也即其实是将原始序列视为一种圆环. 1. 基本用法 默认为右移. Y = circshift(A,K) ...

  2. 分布式系统和CAP

    帽子理论(CAP): C:Consistency,一致性, 数据一致更新,所有数据变动都是同步的 A:Availability,可用性, 好的响应性能,完全的可用性指的是在任何故障模型下,服务都会在有 ...

  3. android 创建一个新的每次project什么时候 请问自己主动 参加 V7依赖?

    android 创建一个新的每次project什么时候 请问自己主动 参加 V7依赖? 分析原因: 主要是由于.我之前的 SDK 的版本号 更新的有点高了.低版本号是不会有这样的问题g的,新版本号中g ...

  4. 权限控制方案之——基于URL拦截

    概述: 在系统开发过程中需要考虑的一个重要的问题就是权限问题,权限问题也是安全问题的一个范畴,我们要求在用户登录系统之后,要控制用户可以访问的系统资源,使得用户只可以访问到系统事先分配好的资源:这里的 ...

  5. POJ1236-Network of Schools(Tarjan + 缩点)

    主题链接 题意:给定一张有向图,问最少选择几个点能遍历全图.以及最少加入几条边使得有向图成为一个强连通图. 思路:对于有向图而言,首先求出有几个强连通分量,之后将每一个强连通分量缩点,形成DAG.本题 ...

  6. CefSharp For WPF响应页面点击事件

    初始化 <!--浏览器--> <cefSharpWPF:ChromiumWebBrowser Name="webBrowser" Grid.Row="0 ...

  7. iPhone开发笔记(20)EGOImageView的使用方法及注意事项

    EGOImageView是一种实现网络图片的异步加载和缓存的第三方类库,具有相同功能的第三方类库还有SDWebImage.但是相比两个类库的安装和使用来说,EGOImageView更简单一些,下面就介 ...

  8. nginx+tomcat反向代理

    第一步:编辑nginx的配置文件 #服务转发一 upstream tomcat8080{ server 192.168.1.6:8080; } #服务转发二 upstream tomcat8081{ ...

  9. IOS开发之delegate和Notification的区别

    delegate针对one-to-one关系,并且reciever可以返回值给sender: notification 可以针对one-to-one/many/none,reciever无法返回值给s ...

  10. github中README.md文件写法解析,git指令速查表

    http://blog.csdn.net/u012234115/article/details/41778701 http://blog.csdn.net/u012234115/article/det ...