![](/img/trans.png)
[英]Failed to connect to port 8080 error when using socket.io and node.js on openshift even when port 8000 specified
[英]node.js not runing properly on port 8080
我試圖使用服務器上安裝的node.js運行一個簡單的http示例。 我正在使用以下代碼:
var http = require('http');
var server = http.createServer(function(req, res)
{
console.log(req, url)
res.writeHead({myinformation:'Welcome To Node.js'});
res.write('Hello world!');
res.end();
});
server.listen(8080);
它將保存到文件example.js中,我使用以下命令通過Putty運行該文件:
$ node example.js
但是問題是當我打開瀏覽器並鍵入: http://myserverip:8080
,在Putty上出現以下錯誤:
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1127:5)
at Object.<anonymous> (/newusr/httpExample/example.js:10:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
我正在使用Win7,並且已按照本指南的說明打開了端口8080的通信,但仍然無法正常工作。
任何幫助,將不勝感激! 謝謝!
當某些其他服務正在偵聽另一個端口時,會出現EACCES錯誤代碼。 嘗試其他端口,或以root用戶身份運行,因為有時您需要那些特權才能綁定到某些端口。
另外,我認為console.log(req, url)
應該是console.log(req.url)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.