突然我收到以下错误nginx的
* Restarting nginx
* Stopping nginx nginx
...done.
* Starting nginx nginx
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
...done.
...done.
如果我运行
lsof -i :80 or sudo fuser -k 80/tcp
我什么也没得到。 没有在端口80
然后我运行下面:
sudo netstat -pan | grep ":80"
tcp 0 0 127.0.0.1:8070 0.0.0.0:* LISTEN 15056/uwsgi
tcp 0 0 10.170.35.97:39567 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39564 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39584 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39566 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39571 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39580 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39562 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39582 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39586 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39575 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39579 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39560 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39587 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39591 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39589 10.158.58.13:8080 TIME_WAIT -
我难倒。
如何调试?
我使用uwsgi用
在端口8070. uwsgi代理通正在运行。 Nginx的是没有的。 我使用Ubuntu 12.4
下面是我的Nginx的conf文件的相关部分
upstream uwsgi_frontend {
server 127.0.0.1:8070;
}
server {
listen 80;
server_name 127.0.0.1;
location = /favicon.ico {
log_not_found off;
}
location / {
include uwsgi_params;
uwsgi_buffering off;
uwsgi_pass 127.0.0.1:8070;
}
}
这是我如何在Ubuntu 12.04安装nginx的
nginx=stable;add-apt-repository ppa:nginx/$nginx;
apt-get update
apt get install nginx-full
Answer 1:
[::]:80
是IPv6地址。
如果你有在端口80,并在端口监听nginx的配置可能会导致该错误[::]:80
。
我有以下我的默认网站可用文件:
listen 80;
listen [::]:80 default_server;
您可以通过添加解决这个ipv6only=on
到[::]:80
是这样的:
listen 80;
listen [::]:80 ipv6only=on default_server;
欲了解更多信息,请参见:
http://forum.linode.com/viewtopic.php?t=8580
http://wiki.nginx.org/HttpCoreModule#listen
Answer 2:
我固定此通过运行sudo apachectl stop
-原来apache的是在后台运行并从开始所期望的端口上的nginx防止。
在Ubuntu上运行sudo /etc/init.d/apache2 stop
Answer 3:
我发现,我从未有过的问题。
我不得不删除/etc/nginx/sites-available/default
。 然后它的工作。
我的conf是/etc/nginx/default
。
Answer 4:
我的情况是不同的,我不得不杀死运行Nginx的重新启动它。
代替
sudo systemctl restart nginx
我不得不使用:
sudo pkill -f nginx
sudo systemctl start nginx
Answer 5:
我也得到同样的错误。
nginx的:[EMERG]绑定()以[:]:80失败(98:地址已在使用)
当我输入在浏览器中的本地主机,然后我就要下船
有用!
这是此服务器的默认网页。
Web服务器软件正在运行,但没有内容已经添加,但。 而不是nginx的欢迎页面,Apache2的是同一个端口上运行,
找到的Apache2 ports.conf文件
sudo /etc/apache2/ports.conf
更改其他的端口,然后80
,我让它为70
保存文件
重新启动系统
它会为你的作品也,如果您输入的浏览器本地主机,你会得到nginx的欢迎页面
Answer 6:
尝试做这个命令
sudo fuser -k 443/tcp
service nginx restart
Answer 7:
我有同样的问题在letsencrypt(certbot)和nginx的,
REF: https://github.com/certbot/certbot/issues/5486
这个错误没有一个尚未解决
所以,一个改变了更新(把一个重装更新后)(使用certbot建议)一个cron
-- in /etc/cron.d/certbot
from
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew
to
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew --pre-hook "service nginx stop" --post-hook "service nginx start"
日志(短):
-- in /var/log/syslog
Jun 10 00:14:25 localhost systemd[1]: Starting Certbot...
Jun 10 00:14:38 localhost certbot[22222]: nginx: [error] open() "/run/nginx.pid$
Jun 10 00:14:41 localhost certbot[22222]: Hook command "nginx" returned error c$
Jun 10 00:14:41 localhost certbot[22222]: Error output from nginx:
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:443 $
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:80 f$
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:443 $
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:80 f$
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:443 $
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:80 f$
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:443 $
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:80 f$
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:443 $
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] bind() to 0.0.0.0:80 f$
Jun 10 00:14:41 localhost certbot[22222]: nginx: [emerg] still could not bind()
Jun 10 00:14:41 localhost systemd[1]: Started Certbot.
-- in /var/log/nginx/error.log
2018/06/10 00:14:27 [notice] 22233#22233: signal process started
2018/06/10 00:14:31 [notice] 22237#22237: signal process started
2018/06/10 00:14:33 [notice] 22240#22240: signal process started
2018/06/10 00:14:34 [notice] 22245#22245: signal process started
2018/06/10 00:14:38 [notice] 22255#22255: signal process started
2018/06/10 00:14:38 [error] 22255#22255: open() "/run/nginx.pid" failed (2: No $
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:443 failed (98: Addr$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:80 failed (98: Addre$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:443 failed (98: Addr$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:80 failed (98: Addre$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:443 failed (98: Addr$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:80 failed (98: Addre$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:443 failed (98: Addr$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:80 failed (98: Addre$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:443 failed (98: Addr$
2018/06/10 00:14:39 [emerg] 22261#22261: bind() to 0.0.0.0:80 failed (98: Addre$
2018/06/10 00:14:39 [emerg] 22261#22261: still could not bind()
Answer 8:
首先改变的apache监听80端口为8080阿帕奇在/etc/apache2/ports.conf包括
Listen 1.2.3.4:80 to 1.2.3.4:8080
sudo service apache2 restart
要么
sudo service httpd restart // in case of centos
然后添加nginx的作为将侦听端口apache的反向代理服务器
server {
listen 1.2.3.4:80;
server_name some.com;
access_log /var/log/nginx/something-access.log;
location / {
proxy_pass http://localhost:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~* ^.+\.(jpg|js|jpeg|png)$ {
root /usr/share/nginx/html/;
}
location /404.html {
root /usr/share/nginx/html/40x.html;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# put code for static content like js/css/images/fonts
}
修改后重启nginx的服务器
sudo service nginx restart
现在,所有的流量将通过nginx的服务器处理和发送所有动态请求,Apache和静态conten由nginx的服务器提供服务。
对于像缓存提前配置:
https://www.linode.com/docs/web-servers/nginx/slightly-more-advanced-configurations-for-nginx/#basic-nginx-caching
Answer 9:
我遇到了类似的问题。 日志是像下面
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
2018/10/31 12:54:20 [emerg] 128005#128005: still could not bind()
2018/10/31 12:54:23 [alert] 127997#127997: unlink() "/run/nginx.pid" failed (2: No such file or directory)
2018/10/31 22:40:48 [info] 36948#36948: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:68
2018/10/31 22:50:40 [emerg] 37638#37638: duplicate listen options for [::]:80 in /etc/nginx/sites-enabled/default:18
2018/10/31 22:51:33 [info] 37787#37787: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:68
最后[emerg]
示出了duplicate listen options for [::]:80
,这意味着有含有多于一个的nginx块文件[::]:80
。
我的解决办法是删除中的一个[::]:80
设置
PS你可能有默认块文件。 我的建议是保持这个文件的默认服务器端口80和删除[::]:80
从其他块文件
Answer 10:
在我的情况下,服务Apache或Apache2的或Nginx的一个已经在运行,并且由于我是无法启动的其他服务。
Answer 11:
我的问题是,我不得不重复听指令。 我设法弄清楚运行重叠指令
grep -r listen /etc/nginx/*
两个文件都在同一个端口监听:
/etc/nginx/conf.d/default.conf: listen 80;
/etc/nginx/sites-enabled/default.conf: listen 80;
Answer 12:
我曾在我的网站,即时拍摄风向不同NGINX配置文件数* .save文件(紧急从纳米转储)。 一旦我删除这些文件.save,NGINX重新启动的罚款。 我认为这些都是无害的,因为没有相应的符号链接,但我想我错了。
Answer 13:
按照上@ lfender6445和@SAURABH答案 -
我的问题是也,升级到2.2.2流浪者后的Apache2正在运行的Web服务器时的来宾引导的事实。 在过去我只用了nginx的作为Web服务器。
流浪汉SSH入禁区,并运行以下命令来启动每当客人箱靴子禁用的Apache2:
sudo update-rc.d -f apache2 remove
退出SSH,流浪汉停止,无业游民了。 问题解决了。
Answer 14:
如果尝试任何上述溶液后问题仍然存在,重新启动服务器一次。 它的工作对我来说:)
文章来源: nginx - nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)