【发布时间】:2014-09-10 23:49:07
【问题描述】:
使用来自 restify 的 README 的示例服务器,它启动并仅绑定到 ipv4 地址上的端口 8080。有没有办法让它绑定到所有地址? Mac OS X。
$ node test.js
myapp listening at http://0.0.0.0:8080
$ netstat -an | grep 8080
tcp4 0 0 *.8080 *.* LISTEN
这有点烦人,因为'localhost'首先尝试v6地址,而一些客户端(例如:curl)不尝试其他地址。我必须记住始终明确输入 127.0.0.1。
$ curl http://localhost:8080/
curl: (7) Failed to connect to localhost port 8080: Connection refused
$ curl http://127.0.0.1:8080/
{"code":"ResourceNotFound","message":"/ does not exist"}
【问题讨论】:
标签: restify