Node.js的应用程序无法在80端口上运行,即使没有其他进程阻塞端口 [英] Node.js app can't run on port 80 even though there's no other process blocking the port

查看:409
本文介绍了Node.js的应用程序无法在80端口上运行,即使没有其他进程阻塞端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行Debian的在Amazon EC2上安装了Node.js的一个实例。如果我运行下面的code:

I'm running an instance of Debian on Amazon EC2 with Node.js installed. If I run the code below:

http = require('http');

http.createServer(function (request, response){
  response.writeHead(200, {'Content-Type':'text/plain'});
  response.end('Hello World\n');
}).listen(80);
console.log("Running server at port 80");

我得到下面还告诉我,输出有另一个进程监听80端口:

I get the output below which tells me there's another process listening at port 80:

Running server at port 80

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> (/home/admin/nodetests/nodetest.js:6:4)
    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)

现在,当我检查,看看是否有一个过程(作为root用户在任何情况下是隐藏的​​)使用的80端口监听:

Now when I check to see if there's a process (as root in case anything is hidden) listening on port 80 using:

netstat -tupln

我得到了下面的输出,它告诉我那里有没有监听80端口:

I get the below output, which tells me theres nothing listening at port 80:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1667/sshd       
tcp6       0      0 :::22                   :::*                    LISTEN      1667/sshd

我应该注意到,Debian有80端口开放为入站规则,如果有差别。

I should note that the debian has port 80 open as an inbound rule if that makes a difference.

我的问题是:我究竟做错了什么?为什么我不能识别的过程中监听80端口?为什么在Debian的封锁?我应该采取什么步骤来获得code正常运行?

My question is: What am I doing wrong? How come I can't identify the process listening to port 80? Why is it blocked in Debian? What steps should I take to get the code running correctly?

推荐答案

错误code EACCES 意味着你没有适当的权限来运行应用程序端口。在Linux系统中,1024以下的任何端口需要root访问权限。

The error code EACCES means you don't have proper permissions to run applications on that port. On Linux systems, any port below 1024 requires root access.

这篇关于Node.js的应用程序无法在80端口上运行,即使没有其他进程阻塞端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆