Learnyounode http服务器ECONNREFUSED

时间:2017-12-02 15:00:33

标签: javascript http

当我想从这段代码启动我的http服务器时:

var http = require('http')
var fs = require('fs')

var port = 8080
var fileName = "test"

http.createServer(function (request, response) {
    fs.createReadStream(fileName).pipe(response)
}).listen(port)

但是当我想要跑步时,我得到了这个输出:

  ✗  Error connecting to
  (http://localhost:25066/api/parsetime?iso=2017-12-02T14:50:54.063Z): connect ECONNREFUSED 127.0.0.1:25066

  ✗  Error connecting to
  (http://localhost:25066/api/unixtime?iso=2017-12-02T14:50:54.063Z): connect ECONNREFUSED 127.0.0.1:25066

有什么问题?

1 个答案:

答案 0 :(得分:0)

ECONREFUSED大部分时间意味着您正在尝试访问已使用的端口。但是,您的错误有些奇怪,因为如上所述,您已设置端口8080来运行您的智能,但错误显示端口25066