- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在运行 node.js 如下:
> http = require('http')
> http.get('http://myhost.local:8080',
function (res) { console.log("RES" + res) }
).on('error', function (e) { console.log("Error:", e) })
> uri = require('url').parse("http://myhost.local:8080")
{ protocol: 'http:',
slashes: true,
auth: null,
host: 'myhost.local:8080',
port: '8080',
hostname: 'myhost.local',
hash: null,
search: null,
query: null,
pathname: '/',
path: '/',
href: 'http://myhost.local:8080/' }
> http.get(uri,
function (res) { console.log("RES" + res) }
).on('error', function (e) { console.log("Error:", e) })
隐式和显式解析的 URI 都抛出错误,我得到以下输出:
Error: { [Error: connect ECONNREFUSED] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' }
主机 myhost.local
是 /etc/hosts
中 localhost
的别名,是:
127.0.0.1 localhost myhost.local myhost
255.255.255.255 broadcasthost
::1 localhost myhost.local myhost
fe80::1%lo0 localhost myhost.local myhost
编辑:我几乎尝试了主机文件的所有排列,包括最明显的排列:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost myhost.local myhost
fe80::1%lo0 localhost
编辑 我还应该提一下,我现在已经在不止一台 Mac 上尝试过了。
虽然这似乎是一个相当常见的错误,但我没有看到任何有用的解释或解决方法。以下是一些值得注意的相关事实:
$ wget http://myhost.local:8080
会按预期工作,因此这不是防火墙问题。$ telnet myhost.local 8080
然后手动获取 url 工作正常,所以这不是一个奇怪的 HTTP 问题。我希望有用的系统信息包括:
$ node -v
v0.9.11
$ uname -a
Darwin myhost.local 12.2.1 Darwin Kernel Version 12.2.1:
Thu Oct 18 12:13:47 PDT 2012; root:xnu-2050.20.9~1/RELEASE_X86_64 x86_64
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.8.2
BuildVersion: 12C3104
$ sudo netstat -nalt | grep LISTEN | grep 8080
tcp6 0 0 ::1.8080 *.* LISTEN
有没有人知道这里发生了什么,以及可能的修复方法是什么?
最佳答案
我会在这里发布这个以防其他人遇到问题。
Bert Belder,Node.js 邮件列表:
On your system "myhost.local" resolves to three different addresses (127.0.0.1, ::1, and fe80::1). Node prefers ipv4 over ipv6 so it'll try to connect to 127.0.0.1. Nothing is listening on 127.0.0.1:8080 so the connect() syscall fails with ECONNREFUSED. Node doesn't retry with any of the other resolved IPs - it just reports the error to you. A simple solution would be to replace 'localhost' by the intended destination ip address, '::1'.
Whether this behavior is right is somewhat open for debate, but this is what causes it.
Bert
关于node.js - 莫名其妙的 node.js http 抛出连接 ECONNREFUSED(IPv6?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15227154/
我正在尝试学习 AngularJS。作为其中的一部分,我想学习使用端到端测试。目前,我有一个这样的目录结构: node_modules .bin ... protractor ..
我收到了 heroku run any_command_here 的 ECONNREFUSED。 Heroku 登录成功。其他 heroku 命令也成功(应用程序、发布、共享)。应用程序正在运行。我什
我以前可以运行它。但现在我不能了。它是在一个项目中。我的 friend 从 git latst 存储库(这也是我导入的方式)拥有这个项目,可以使用 gulp protractor qa 在网关下运行
我是 node.js 和 Selenium 的新手,所以如果我没有立即提供所需的所有详细信息,请多多包涵。 这是我想在 FF 中运行的非常简单的测试(我在这里发现了很多这样的问题,但它们指的是 Chr
我在一个模拟的(facebook/google)策略上运行一些测试但是当我一个一个地运行这些测试时我遇到的问题是它正在运行但是当我同时运行它们时它们在第一次测试后不工作,连接应用程序立即失败。 我尝试
我在我的电子桌面应用程序中使用 NodeJS selenium。 "electron-chromedriver": "^4.0.0-beta.1", "selenium-webdriver": "^4
在 selenium Node js 上运行测试用例遇到错误错误:ECONNREFUSED 连接 ECONNREFUSED。 测试用例 var assert = require('assert'),
MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect
我用下面的代码连接到php websocket。 serverAddr = InetAddress.getByName(ip_str); socket = new So
我正在开发一个应用程序,我想我想做的是从 android 中的服务器数据库接收数据。所以我开始运行一些教程。我找到了一个正在做我想做的事的人。但我得到: detailMessage "failed
我有两个docker-compose设置,主要服务是SPA,其中包含: nginx代理,用于端口80上的wordpress wordpress + mysql expressjs用于服务React应用
我正在尝试将一个值插入到我的数据库中,该数据库是 mydb 并且该表是使用 2 个字段用户名和密码登录的。我正在使用 express.js 和 MySQL。插入查询代码为 exports.insert
在我正在开发的 Sails.js 应用程序中,我随机遇到了一个 ECONNREFUSED 错误。我试图检查引发错误的代码片段,但没有成功。我已经将日志切换为详细(NODE_DEBUG 环境变量设置为“
我是 nodejs 和 express 的新手。我正在使用“请求”库来阅读 google.com 的内容。我不断收到连接被拒绝的错误。我从 https://github.com/request/req
所以我正在尝试编写一个discord.js 机器人!我应该将discord bot 记录在 channel 中发送到mysql 的所有消息。我在互联网上搜索过,但没有找到解决我的问题的方法。前任。 n
我正在运行一个以 mysql 作为我的数据库的 Node 应用程序(也使用 sequelize 作为 ORM)。每当我使用“node”命令运行“app.js”文件时,我都会收到错误消息: { [错误:
我使用以下方法创建了一个套接字:socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)。 根据 this ,如果我多次发送简单数据包(乘以 send() 和/或 sendto
AssertionError: null == {"name":"MongoError","message":"connect ECONNREFUSED"} 我遇到断言错误。 我尝试使用 NodeJS
我正在学习 learnyounode 教程来学习 Node.js。每当我尝试安装软件包时都会收到错误。 npm ERR! Linux 4.2.0-c9 npm ERR! argv "/home/ubu
我已尝试使用此代码从我的 android 应用程序向服务器发送数据。 try { HttpClient httpClient = new DefaultHttpClient(); Ht
我是一名优秀的程序员,十分优秀!