var http = require('http');
http.createServer(function(request,response){
response.writeHead(200,{"Content-Type":"text/plain"});
response.write("Hello, world!");
response.end();
}).listen(8888,'127.0.0.2');
然而,当我跑node test.js
我
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRNOTAVAIL
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at net.js:1143:9
at dns.js:72:18
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:902:3
127.0.0.1
无论是否指定IP地址,它都能正常工作。谁能解释为什么会发生错误,以及如何正确指定地址?
要使用该地址,您必须在系统上为该接口配置该地址。您的回送接口配置为127.0.0.1。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句