突然,我得到了下面的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 -
我被难住了。我该如何调试它?
我在端口8070上使用带有代理传递的uwsgi。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
发布于 2013-02-27 07:52:48
[::]:80
是一个ipv6地址。
如果您的nginx配置正在侦听端口80和端口[::]:80
,则会导致此错误。
我的默认sites-available文件中有以下内容:
listen 80;
listen [::]:80 default_server;
您可以通过将ipv6only=on
添加到[::]:80
来修复此问题,如下所示:
listen 80;
listen [::]:80 ipv6only=on default_server;
有关详细信息,请参阅:
发布于 2013-05-29 01:27:13
我通过运行sudo apachectl stop
修复了这个问题-原来apache是在后台运行的,并阻止nginx在所需的端口上启动。
在ubuntu上运行sudo /etc/init.d/apache2 stop
发布于 2018-08-03 11:22:57
我的情况不同,我不得不终止运行Nginx来重启它。
而不是
sudo systemctl restart nginx
我不得不使用:
sudo pkill -f nginx & wait $!
sudo systemctl start nginx
https://stackoverflow.com/questions/14972792
复制相似问题