突然间,我得到了以下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.
Run Code Online (Sandbox Code Playgroud)
如果我跑
lsof -i :80 or sudo fuser -k 80/tcp
Run Code Online (Sandbox Code Playgroud)
我一无所获.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 -
Run Code Online (Sandbox Code Playgroud)
我很难过.
怎么调试?
我正在使用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;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我在ubuntu 12.04上安装nginx的方法
nginx=stable;add-apt-repository ppa:nginx/$nginx;
apt-get update
apt get install nginx-full
Run Code Online (Sandbox Code Playgroud)
lfe*_*445 214
我通过运行修复此问题sudo apachectl stop- 结果是apache在后台运行并阻止nginx在所需的端口上启动.
在ubuntu上运行 sudo /etc/init.d/apache2 stop
Nat*_*han 196
[::]:80 是一个ipv6地址.
如果您的nginx配置正在侦听端口80以及端口上,则可能导致此错误[::]:80.
我在默认站点 - 可用文件中有以下内容:
listen 80;
listen [::]:80 default_server;
Run Code Online (Sandbox Code Playgroud)
您可以通过添加以下内容ipv6only=on来解决此[::]:80问题:
listen 80;
listen [::]:80 ipv6only=on default_server;
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅:
http://forum.linode.com/viewtopic.php?t=8580
http://wiki.nginx.org/HttpCoreModule#listen
dat*_*uoc 51
我的情况不同,我不得不杀死运行Nginx重新启动它.
代替
sudo systemctl restart nginx
Run Code Online (Sandbox Code Playgroud)
我不得不使用:
sudo pkill -f nginx
sudo systemctl start nginx
Run Code Online (Sandbox Code Playgroud)
Tam*_*mpa 33
我发现了以前从未有过的问题.
我只是要删除/etc/nginx/sites-available/default.然后它奏效了.
我的conf是在/etc/nginx/default.
小智 23
我也得到了同样的错误.nginx:[emerg] bind()到[::]:80失败(98:地址已经在使用中),当我在浏览器中键入localhost时,我得到了
有用!
这是此服务器的默认网页.
Web服务器软件正在运行,但尚未添加任何内容.而不是nginx欢迎页面,apache2在同一个端口上运行,
找到apache2 ports.conf文件
sudo /etc/apache2/ports.conf
更改80以外的端口,我将其设为70
保存文件
重启你的系统
它也适用于您,如果您在浏览器中键入localhost,您将获得nginx欢迎页面
Bla*_*ack 12
我的问题是我有重叠的听指令。我设法通过运行找出重叠的指令
grep -r listen /etc/nginx/*
Run Code Online (Sandbox Code Playgroud)
两个文件在同一个端口上侦听:
/etc/nginx/conf.d/default.conf: listen 80;
/etc/nginx/sites-enabled/default.conf: listen 80;
Run Code Online (Sandbox Code Playgroud)
小智 8
多个服务可以侦听同一端口。此问题通常是由于在同一台计算机上混合使用 Apache 和 NGINX 造成的。
去检查:
sudo netstat -plant | grep 80
停止 Apache 并重新启动 NGINX:
sudo systemctl stop apache2 && sudo systemctl restart nginx && sudo systemctl status nginx
尝试执行此命令
sudo fuser -k 443/tcp
service nginx restart
Run Code Online (Sandbox Code Playgroud)
我使用 Supervisor 在 Docker 容器上并行运行 Nginx 和 Gunicorn。
这是主管使用的配置:
[supervisord]
nodaemon=true
[program:gunicorn]
command = /project/start.sh
user = www-data
[program:nginx]
command=/usr/sbin/nginx
Run Code Online (Sandbox Code Playgroud)
问题是我如何启动 Ngnix,默认情况下它在前台运行。这使得主管重试运行 Nginx 的另一个实例。
您可以通过添加-g 'daemon off;'到命令行或daemon off;配置文件顶部来解决问题,Nginx 留在前台,主管停止尝试运行另一个实例。
我通过运行解决了
sudo killall apache2
sudo fuser -k 443/tcp
Run Code Online (Sandbox Code Playgroud)
最后
sudo service nginx start
Run Code Online (Sandbox Code Playgroud)
我在letencrypt(certbot)和nginx中遇到了同样的问题,
参考:https : //github.com/certbot/certbot/issues/5486
此错误尚无解决方法
因此,更改了cron以进行续订(在续订后重新加载)(使用certbot的建议)
-- 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"
Run Code Online (Sandbox Code Playgroud)
日志(简短):
-- 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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
214729 次 |
| 最近记录: |