得到 (13)Permission denied: make_sock: could not bind to address [::]:9000 错误的原因是啥?

Posted

技术标签:

【中文标题】得到 (13)Permission denied: make_sock: could not bind to address [::]:9000 错误的原因是啥?【英文标题】:what was the reason to get (13)Permission denied: make_sock: could not bind to address [::]:9000 error?得到 (13)Permission denied: make_sock: could not bind to address [::]:9000 错误的原因是什么? 【发布时间】:2016-04-24 15:05:12 【问题描述】:

我正在尝试在同一 IP 地址的不同端口上配置两个站点。

(13)Permission denied: make_sock: could not bind to address [::]:9000

我收到错误消息。这个错误的原因是什么以及如何解决这个错误?

我的httpd.conf 文件是

Listen 80
NameVirtualHost 192.168.2.10:80
<VirtualHost 192.168.2.10:80>
DocumentRoot /var/www/html/white-socks
ServerName www.white-socks.com
</VirtualHost>
Listen 9000
NameVirtualHost 192.168.2.10:9000
<VirtualHost 192.168.2.10:9000>
DocumentRoot /var/www/html/black-socks
ServerName www.black-socks.com
</VirtualHost>

我收到如下错误。

[root@ram conf]# service httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for ram
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:9000
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:9000
no listening sockets available, shutting down
Unable to open logs
                                                           [FAILED]
[root@ram conf]# 

我该怎么做才能解决这个问题?

【问题讨论】:

阅读bind(2) 【参考方案1】:

有两个问题需要解决:

    httpd 的权限和访问权限 端口访问

    第一个问题涉及所有权,这可能是您的服务器没有正确的权限,您需要 chmod 一个文件夹(显然 不是您的文档根目录或连接到网络服务器的用户拥有的任何文件夹进入)。检查这是否是在终端中运行的问题

sudo httpd

sudo 允许您以 root 身份运行命令。如果它正常工作,那么它是一个权限问题。

    只有一台服务器可以访问分配给它的一个端口。如果另一台服务器访问同一端口,它将被拒绝访问该端口。因此,如果您有两台服务器,它们就不能同时在同一个端口上运行。您将需要更改适当的配置文件来限制访问端口 80、8080 或 9000 的服务器的范围。如果您有默认的 apache 服务器(有时在 MacOS 中就是这种情况),那么您将需要限制其范围或完全禁用它。

sudo bash -x /usr/sbin/apachectl -k stop

将停止 MacOS 中的默认服务器

sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist

将在启动时停止未来运行

【讨论】:

【参考方案2】:

如果您使用的是 Selinux(仅适用于 RedHat 基本操作系统)并且未正确配置,则很多时候会发生此错误。尝试通过setenforce 0 禁用 Selinux,或者如果您不想禁用 selinux 而不是通过以下方式正确配置 selinux:-

semanage port -l | grep http
semanage port -a -t http_port_t -p tcp 9000

重新启动您的 apache 服务器并检查。

您还可以检查 netstat 命令的输出以查看端口是否已被使用。

netstat -tunalp | grep :9000

netstat -tunalp | grep :80

【讨论】:

以上是关于得到 (13)Permission denied: make_sock: could not bind to address [::]:9000 错误的原因是啥?的主要内容,如果未能解决你的问题,请参考以下文章

Apache 403 error, (13)Permission denied: access to / denied问题

Python UDP broadcast PermissionError: [Errno 13] Permission denied

Unicorn 和 nginx (13: Permission denied)

PermissionError: [Errno 13] Permission denied

当 conda install django, PermissionError(13, 'Permission denied')

PermissionError: [Errno 13] Permission denied: