Nginx 将无法启动(地址已被使用)

标签 nginx

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

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命令发送信号。

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。

关于Nginx 将无法启动(地址已被使用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42303401/

相关文章:

ruby-on-rails - 调试 502 Bad Gateway 错误 - Ubuntu、Nginx、Unicorn

PHP session 不存储/保存 - php-fpm/nginx/phpmyadmin/centos6

reactjs - 当路径不是 "/"时,react-router + nginx 入口刷新会导致白屏

ruby - 当 nginx 获取 memcached Rack 结果时显示添加的奇怪字符串

nginx - 为什么来自在Nginx上运行的应用程序的传出请求不会影响Kubernetes服务

regex - Nginx 重写 : add trailing slash, 保留 anchor 和查询字符串

unix - 如何在不丢失任何请求的情况下升级Nginx?

整个子网的 Nginx 速率限制计数,而不仅仅是每个 IP

ssl - NGINX 中不同 SSL 端口的不同 SSL ssl_verify_client 不起作用

configuration - 如何在 Nginx 上使用 FastCGI 防止网关超时