我试图启动一个 nodejs 服务器,发现它无法绑定(bind)端口 8000 或 8080、1234、12345....
Error: listen EACCES
如果我禁用 selinux (echo 0 >/selinux/enforce) 或者如果我以 root 身份运行它,它就会工作。
它是 nodejs 的东西吗? python -m SimpleHTTPServer 8000 也失败了。
socket.error: [Errno 13] Permission denied
然后我尝试了端口 54321,它工作,32768,工作,32767,不行。 好的,如果 python 和 nodejs 都可以工作
the port > 32767
或
selinux disabled
或
has root privilege
node 和 python 都通过 yum install 安装到/usr/bin。
-rwxr-xr-x. root root system_u:object_r:bin_t:s0 node
-rwxr-xr-x. root root system_u:object_r:bin_t:s0 python
哪个 selinux 策略导致了这个?
这是一个更新的 Centos 6.4 x64 minimal box。
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
最佳答案
您可以尝试查看端口是否在 SELinux 中打开:
semanage port -l | grep 8000
如果它不在列表中,您可以尝试打开该端口:
semanage port -a -t http_port_t -p tcp 8000
关于linux - selinux 阻止用户监听小于 32768 的端口(不,它大于 1024),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20208208/