Node proxy error Error: connect ECONNREFUSED

I am using a reverse proxy from the following module https://github.com/nodejitsu/node-http-proxy

and i ended up in err for the following code

proxy.on('error', function (err, req, res) {
    res.end('Error occurr'+ err);
});

connect ECONNREFUSED , what does this error mean and what might be possible for it?

I use

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 just need proxy calls to the new port

+4
source share
1 answer

ECONNREFUSED means that the server process is not listening on the specified port. What hostname, and portdo you use? Can you connect directly (without proxy)?

P.S. ECONNREFUSED, changeOrigin , proxy.web:

proxy.web(req, res, {
    target: 'http://' + hostname + ':' + port,
    changeOrigin: true
});
+7

Source: https://habr.com/ru/post/1610499/


All Articles