Nginx 无法启动(地址已被使用) [英] Nginx will not start (Address already in use)

查看:33
本文介绍了Nginx 无法启动(地址已被使用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 nginx 有问题.我尝试了不同的解决方案,但对我来说没有任何效果.这是我的错误:

I have a problem with nginx. I tried different solutions, but for me nothing work. That is my error:

4 root@BANANAS ~ # sudo service nginx restart                                :(
Restarting nginx: nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] still could not bind()
nginx.

你能帮我吗?

推荐答案

可能其他进程正在使用指定端口:

sudo netstat -tulpn

获取已经使用443的进程的PID,并用kill命令发送信号.

Get the PID of the process that already using 443. And send signal with kill command.

sudo kill -2 <PID>

sudo service nginx restart

或者你可以这样做:

sudo fuser -k 443/tcp

确保不要使用旧语法:

server {
    listen :80;
    listen [::]:80;
}

上面的语法会导致

nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

正确的语法:

server {
    listen 80;
    listen [::]:80 ipv6only=on;
}

server {
    listen [::]:80;
}

以上两种语法都可以实现相同的目的,同时监听 ipv4 和 ipv6.

Both above syntax will achieve the same thing, listening on both ipv4 and ipv6.

这篇关于Nginx 无法启动(地址已被使用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆