节点代理错误错误:连接ECONNREFUSED [英] node proxy error Error: connect ECONNREFUSED
问题描述
我使用以下模块中的反向代理https://github.com/nodejitsu/node-http-proxy
I use reverse proxy from the following module https://github.com/nodejitsu/node-http-proxy
我在下面的代码中犯了错误
and I got in err for the following code
proxy.on('error', function (err, req, res) {
res.end('Error occurr'+ err);
});
connect ECONNREFUSED这个错误是什么意思,有什么可能的解决方法?
connect ECONNREFUSEDwhat does it mean this error and what can be possible solution to it?
我使用
proxy = httpProxy.createProxyServer({});
proxy.web(req, res, {
target: 'http://' + hostname + ':' + port
});
proxy.on('error', function (err, req, res) {
res.end('Error occurr'+ err);
});
我只需要代理对新端口的调用
and I need just to proxy calls to new port
推荐答案
ECONNREFUSED 表示没有服务器进程在指定端口侦听.您使用的是什么 hostname
和 port
?可以直接连接吗(不用代理)?
ECONNREFUSED means there is no server process listening at the specified port. What hostname
and port
are you using? Can you connect directly (without the proxy)?
附言与 ECONNREFUSED 无关,但您还应该在传递给 proxy.web 的选项中设置 changeOrigin:
P.S. Unrelated to ECONNREFUSED, but you should also set changeOrigin in the options passed to proxy.web:
proxy.web(req, res, {
target: 'http://' + hostname + ':' + port,
changeOrigin: true
});
这篇关于节点代理错误错误:连接ECONNREFUSED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!