[英]ECONNREFUSED when starting node express application
events.js:141
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:4562
at Object.exports._errnoException (util.js:837:11)
at exports._exceptionWithHostPort (util.js:860:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1060:14)
here is my code 这是我的代码
var express = require('express');
var net = require('net');
var app = express();
var i = 0;
app.get('/', function (req, res)
{
i = i+1; //no of clinets request gin ne ki liye
console.log(i + "fa..sa");
var client = net.connect({port: 4562},"192.168.202.101", function() {
console.log('connected to server!'); });
client.write("Ho gaya bhai");
client.end();
res.send('ho gaya bhai..');
});
app.listen(6544);
As you can see from your error message you have an error in the way you call net.connect
. 从错误消息中可以看到,您调用net.connect
的方式存在错误。 It looks like you want to connect to 192.168.202.101:4562
, but you try to connect to ´127.0.0.1:4562´. 看起来您想连接到192.168.202.101:4562
,但是您尝试连接到“ 127.0.0.1:4562”。 Try either: 尝试以下任一方法:
net.connect({ port: 4562, host: "192.168.202.101"}, function(){});
or: 要么:
net.connect(4562, "192.168.202.101", function() {});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.