Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

javascript - 如何解决错误:使用nodejs时监听EADDRINUSE?(How to fix Error: listen EADDRINUSE while using nodejs?)

If I run a server with the port 80, and I try to use xmlHTTPrequest i get this error: Error: listen EADDRINUSE(如果我使用端口80运行服务器,并且尝试使用xmlHTTPrequest,则会收到此错误: Error: listen EADDRINUSE)

Why is it problem for nodejs, if I want to do a request, while I run a server on the port 80?(在80端口上运行服务器时,如果要发出请求,为什么nodejs会出现问题?) For the webbrowsers it is not a problem: I can surf on the internet, while the server is running.(对于网络浏览器而言,这不是问题:服务器运行时,我可以在Internet上冲浪。) The server is:(服务器是:) net.createServer(function (socket) { socket.name = socket.remoteAddress + ":" + socket.remotePort; console.log('connection request from: ' + socket.remoteAddress); socket.destroy(); }).listen(options.port); And the request:(并要求:) var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { sys.puts("State: " + this.readyState); if (this.readyState == 4) { sys.puts("Complete. Body length: " + this.responseText.length); sys.puts("Body: " + this.responseText); } }; xhr.open("GET", "http://mywebsite.com"); xhr.send();   ask by Danny Fox translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What really helped for me was:(对我真正的帮助是:)

killall -9 node But this will kill a system process.(但这会杀死系统进程。) With(用) ps ax you can check if it worked.(您可以检查它是否有效。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...