【问题标题】:nginx - nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)nginx - nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
【发布时间】:2013-02-05 00:54:07
【问题描述】:

突然间我收到以下 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 配置文件的相关部分

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

【问题讨论】:

  • 我发现了以前从未遇到过的问题。我不得不删除 /etc/nginx/sites-available/default。然后它起作用了。我的 conf 在 /etc/nginx/default
  • 我正在运行 Nginx+Varnish 并出现此错误。解决方案是先停止两者,然后先启动 nginx,然后再启动 varnish。
  • 您可以尝试停止命名服务。
  • 您是否已从启用站点中删除了默认设置?
  • 我在这里尝试了所有解决方案。检查所有正在使用的端口(NGINX 本身正在使用它)所以我关闭了端口并重新启动它。像魅力一样工作。

标签: ubuntu nginx


【解决方案1】:

我发现了以前从未遇到过的问题。

我只需要删除/etc/nginx/sites-available/default。然后就成功了。

此删除将仅删除符号链接,作为备份,您可以在以下位置找到默认文件 /etc/nginx/sites-enabled/default

我的 conf 在/etc/nginx/default

【讨论】:

  • +1 这个解决方案对我有用,但后来我认为默认情况下一定有某些东西实际上导致了问题,所以我深入挖掘并提供了一个包含更多信息的答案。
  • 我认为删除默认站点配置模板并不是最好的解决方案 - 在同一模板中注释包含 listen 80; 的行已经解决了问题,而且是正确的。你的把戏很有效,但这不是我未来的读者会做的事情。这就是为什么我建议您选择@Nathan 的答案作为正确答案。
  • 我在运行apt-get dist-upgrade后遇到了同样的问题,升级了nginx包,在/etc/nginx/sites-enabled中创建了一个链接到/etc/nginx/sites-available/default。 nginx 试图加载这个默认配置,它通过 IPv6 侦听端口 80,然后它还加载了我读取的真实配置。删除该符号链接解决了问题。
  • 您不需要删除 /etc/nginx/sites-available/default,只需删除指向它的符号链接 - sudo rm /etc/nginx/sites-enabled/default
  • 我在尝试在端口 8080 上运行 nginx 和在端口 80 上运行 varnish 时遇到此问题,与此答案类似,我发现问题出在 nginx 默认配置仍在侦听端口80 即使我的 sites-available 配置都在端口 8080 上侦听。这位于 /etc/nginx/conf.d/default
【解决方案2】:

[::]:80 是一个 ipv6 地址。

如果您的 nginx 配置正在侦听端口 80 以及端口 [::]:80,则可能会导致此错误。

我的默认站点可用文件中有以下内容:

listen 80;
listen [::]:80 default_server;

您可以通过将ipv6only=on 添加到[::]:80 来解决此问题,如下所示:

listen 80;
listen [::]:80 ipv6only=on default_server;

有关详细信息,请参阅:

http://forum.linode.com/viewtopic.php?t=8580

http://wiki.nginx.org/HttpCoreModule#listen

【讨论】:

  • 你也可以通过去掉listen 80来修复它;因为 listen [::]:80 监听 IPv4 和 IPv6。不过要小心,因为某些系统(如 FreeBSD)将 IPv4 和 IPv6 套接字分开,然后它就不起作用了,但对于 Linux 来说应该没问题。 wiki.nginx.org/HttpCoreModule#listen
  • 感谢您深入研究并解释为什么删除 /etc/nginx/sites-available/default 有助于解决上述错误。
  • 即使我注释掉了 ipv6 行,当我尝试sudo service nginx restart 时仍然会遇到同样的错误。当我做netstat -tulpn |grep 80 时,我只得到一次 nginx 进程(0.0.0.0:80)。任何想法为什么它不会重新启动?
  • 我赞同@rednaw 所说的,但不是删除监听,你可以简单地把它注释掉
  • 设置ipv6only=on 解决了这个问题,但是nginx应该真正检测到它正在尝试绑定到同一个接口:端口两次。
【解决方案3】:

我通过运行sudo apachectl stop 解决了这个问题 - 结果发现 apache 正在后台运行并阻止 nginx 在所需端口上启动。

在 ubuntu 上运行 sudo /etc/init.d/apache2 stop

【讨论】:

  • 在 Ubuntu 14.04 上使用 sudo /etc/init.d/apache2 stop 停止 apache
  • 原因是你不能让两个 Web 服务器监听同一个端口。选择一个,如果需要,代理。例如。使用 nginx,但对于某些请求(例如 php 文件),代理到 Apache 端口。
  • 谢谢。但你知道为什么它突然开始了吗?一个星期没碰服务器,昨晚就开始了。
  • 也许您的服务器已重新启动并且您已将 apache 配置为在启动时启动?和/或其他服务需要 apache 作为依赖项。了解更多有关您的操作系统设置的信息也可能会有所帮助
  • 感谢您的解决方案。它对我有用,我使用 Google Cloud Platform
【解决方案4】:

我也遇到了同样的错误。

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

当我在浏览器中输入本地主机时,我得到了

有效!

这是此服务器的默认网页。

网络服务器软件正在运行,但尚未添加任何内容。 而不是 nginx 欢迎页面,apache2 正在同一个端口上运行,

  1. 找到 apache2 ports.conf 文件

    sudo /etc/apache2/ports.conf
    
  2. 更改80以外的端口,我将其设置为70

  3. 保存文件

  4. 重启系统

它也适用于你,如果你在浏览器中输入 localhost,你会得到 nginx 欢迎页面

【讨论】:

  • 您可能根本不想同时运行 Apache2 和 nginx。我发现 Apache 安装启动了服务。于是,我发出“sudo /etc/init.d/apache2 stop”,然后就可以正常启动nginx了。这也使您免于重新启动系统。
  • 你说得对,删除 /etc/nginx/sites-enabled/default 符号链接确实会阻止它监听两个端口。我发现每个关于 nginx 的教程都以建议每个人删除“默认”链接开始,但我认为这是一个不同的主题,这实际上有点烦人。
  • @IgorGanapolsky 将 Apache 切换到不同的端口?
【解决方案5】:

我的站点可用目录中有几个来自不同 NGINX 配置文件的 *.save 文件(来自 nano 的紧急转储)。删除这些 .save 文件后,NGINX 重新启动正常。我认为这些是无害的,因为没有相应的符号链接,但我想我错了。

【讨论】:

    【解决方案6】:

    尝试执行此命令

    sudo fuser -k 443/tcp
    service nginx restart
    

    fuser 命令将找到进程 id(PID),-k 标志将杀死启用 nginx 重启的进程。

    【讨论】:

    • 这很完美:)
    【解决方案7】:

    首先将apache监听端口80改为8080 /etc/apache2/ports.conf 中的 apache 包含

    Listen 1.2.3.4:80 to 1.2.3.4:8080
    sudo service apache2 restart 
    

    sudo service httpd restart    // in case of centos
    

    然后添加 nginx 作为反向代理服务器,将监听 apache 端口

    server {
     listen   1.2.3.4:80;
     server_name  some.com;
    
     access_log  /var/log/nginx/something-access.log;
    
     location / {
      proxy_pass http://localhost:8080;
      proxy_redirect off;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }
    
    
    location ~* ^.+\.(jpg|js|jpeg|png)$ {
       root /usr/share/nginx/html/;
    }
    
    location /404.html {
      root /usr/share/nginx/html/40x.html;
    }
    
    error_page 404 /404.html;
        location = /40x.html {
    }
    
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
    
    # put code for static content like js/css/images/fonts
    }
    

    修改后重启nginx服务器

    sudo service nginx restart
    

    现在所有流量都将由 nginx 服务器处理,并将所有动态请求发送到 apache,静态内容由 nginx 服务器提供服务。

    对于像缓存这样的高级配置:

    https://www.linode.com/docs/web-servers/nginx/slightly-more-advanced-configurations-for-nginx/#basic-nginx-caching

    【讨论】:

      【解决方案8】:

      我在letsencrypt(certbot)和nginx中遇到了同样的问题,

      参考:https://github.com/certbot/certbot/issues/5486

      这个错误还没有解决办法

      所以,a 更改了更新的 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"
      

      日志(短):

      -- 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()
      

      【讨论】:

      • 超级随机,但我相信这是我的问题。感谢您发布此内容。我的错误似乎是因为它试图更新一个过时的域条目,但因为我不再控制域而无法更新。
      • 我想这可能也是我的问题。但我需要等待看看
      【解决方案9】:

      我的情况不同,我必须杀死正在运行的 Nginx 才能重新启动它。

      代替

      sudo systemctl restart nginx
      

      我不得不使用:

      sudo pkill -f nginx & wait $!
      sudo systemctl start nginx
      

      【讨论】:

      • 我正在服用 404 Not Found,我使用了你的建议,现在我确实解决了我的问题。谢谢。
      • 这对我有用。其他什么都没做。不确定系统重新启动时会启动什么进程,但我将在我的重新启动 nginx 例程中添加它。谢谢!
      • 这个解决方案解决了我的问题?
      • 最好坚持以一种方式在您的 nginx 服务上运行。我通过使用nginx -s reload 而不是使用systemctl 让它进入了一个糟糕的状态
      • 我爱你;谢谢。 sudo pkill -f nginx & wait $! 拯救了这一天。
      【解决方案10】:

      我遇到了类似的问题。日志如下所示

      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to 0.0.0.0:443 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: bind() to [::]:80 failed (98: Address already in use)
      2018/10/31 12:54:20 [emerg] 128005#128005: still could not bind()
      2018/10/31 12:54:23 [alert] 127997#127997: unlink() "/run/nginx.pid" failed (2: No such file or directory)
      2018/10/31 22:40:48 [info] 36948#36948: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:68
      2018/10/31 22:50:40 [emerg] 37638#37638: duplicate listen options for [::]:80 in /etc/nginx/sites-enabled/default:18
      2018/10/31 22:51:33 [info] 37787#37787: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:68
      

      最后一个[emerg]显示duplicate listen options for [::]:80,这意味着有不止一个nginx块文件包含[::]:80

      我的解决方案是删除[::]:80 设置之一

      附:你可能有默认的块文件。我的建议是将此文件保留为端口 80 的默认服务器。并从其他块文件中删除 [::]:80

      【讨论】:

      • 我这样做了,我已从其他配置文件 [::]:80 及其工作中删除!但它安全吗?什么时候没有默认监听器?
      【解决方案11】:

      继续@lfender6445 和@SAURABH 的回答——

      我的问题还在于,在升级到 Vagrant 2.2.2 后,当访客启动时,Apache2 正在作为 Web 服务器运行。过去我只有 nginx 作为 web 服务器。

      vagrant ssh 进入盒子并运行以下命令以禁用 Apache2 在访客盒子启动时启动:

      sudo update-rc.d -f apache2 remove
      

      退出ssh,vagrant stop,vagrant up。问题解决了。

      【讨论】:

        【解决方案12】:

        如果在尝试上述任何解决方案后问题仍然存在,请重新启动服务器一次。它对我有用:)

        【讨论】:

        • 是的,它会的。但是杀死 nginx 进程然后重新启动 nginx 也可以。这就是@datdinhquoc 的答案。
        【解决方案13】:

        就我而言,Apache、Apache2 或 Nginx 服务之一已经在运行,因此我无法启动另一个服务。

        【讨论】:

          【解决方案14】:

          我的问题是我有重叠的监听指令。我已经设法通过运行找出重叠的指令

          grep -r listen /etc/nginx/*
          

          两个文件在同一个端口监听:

          /etc/nginx/conf.d/default.conf:           listen 80;  
          /etc/nginx/sites-enabled/default.conf:    listen 80;
          

          【讨论】:

          • 这是一种非常简洁的检查方式:grep -r listen /etc/nginx/* 感谢分享!
          • 谢谢先生!但是,一个问题是,将另一个侦听端口 80 修改为假设 70 不会导致任何错误吗?
          【解决方案15】:

          在我的例子中,罪魁祸首原来是一个服务器块,其中包含:

                  listen  127.0.0.1:80;
                  listen  [::1]:80 ipv6only=on;
                  server_name  localhost;
          

          在 Linux 上,侦听特定 IP(例如 [::1]:80)的套接字与侦听同一端口但任何 IP(例如 [::]:80)的套接字冲突。通常情况下,nginx 会通过在后台使用单个套接字来透明地处理这个问题。但是,在 listen 指令上显式指定 ipv6only(或某些其他选项)会强制 nginx(尝试)为其创建单独的套接字,从而导致 Address already in use 错误。

          因为ipv6only=on 无论如何都是默认值(自 1.3.4 起),所以修复只是从该指令中删除该选项,并确保在我的配置中的其他任何地方都没有使用 ipv6only

          【讨论】:

            【解决方案16】:

            我使用 supervisor 在 Docker 容器上并排运行 Nginx 和 Gunicorn。

            这是用于主管的配置:

            [supervisord]
            nodaemon=true
            
            [program:gunicorn]
            command = /project/start.sh
            user = www-data
            
            [program:nginx]
            command=/usr/sbin/nginx
            

            问题是我如何默认启动 Ngnix,它在前台运行。这使得 主管重试 以运行另一个 Nginx 实例。

            您可以通过在命令行中添加-g 'daemon off;' 或在配置文件顶部添加daemon off; 来解决问题,Nginx 停留在前台,主管停止尝试运行另一个实例。

            【讨论】:

              【解决方案17】:

              我有同样的问题,但我看到 Nginx 监听了端口 80:

              tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      9730/nginx 
              

              但是当我尝试重新启动它时,我遇到了错误:

                  service nginx restart
              Stopping nginx:                                            [FAILED]
              Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
              nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
              nginx: [emerg] still could not bind()
              

              我的问题出在配置文件中,我设置了 PID 文件,但系统似乎无法正确捕获它:

              user nginx;
              worker_processes 1;
              error_log /var/log/nginx/error.log;
              pid /run/nginx.pid;
              

              当我删除它时,它起作用了。

              【讨论】:

                【解决方案18】:

                我在 AWS Lightsail 上遇到了这个错误,使用了上面的最佳答案

                来自

                listen [::]:80;
                

                listen [::]:80 ipv6only=on default_server;
                

                然后点击我的 AWS 账户中的“重启”按钮,我有主服务器 Apache 和 Nginx 作为代理。

                【讨论】:

                  【解决方案19】:

                  我知道这是旧的,但还要确保你的 docker 容器都没有在端口 80 上。这是我的问题。

                  【讨论】:

                  • 与此类似,在我的情况下,我有 haproxy 正在运行
                  【解决方案20】:

                  我通过运行解决了

                  sudo killall apache2
                  
                  sudo fuser -k 443/tcp
                  

                  终于

                  sudo service nginx start
                  

                  【讨论】:

                    【解决方案21】:

                    多个服务可以监听同一个端口。 这个问题通常来自于在同一台机器上混合使用 Apache 和 NGINX。

                    检查:

                    sudo netstat -plant | grep 80

                    停止 Apache 并重新启动 NGINX:

                    sudo systemctl stop apache2 && sudo systemctl restart nginx && sudo systemctl status nginx

                    【讨论】: