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

查看:397
本文介绍了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

或者,您可以执行以下操作:

Aternatively you can do:

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天全站免登陆