312

突然、以下の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
4

21 に答える 21

340

実行してこれを修正しましsudo apachectl stopた-Apacheがバックグラウンドで実行されていて、nginxが目的のポートで起動できないことがわかりました。

Ubuntuの実行時sudo /etc/init.d/apache2 stop

于 2013-05-28T17:27:13.493 に答える
222

[::]:80ipv6 アドレスです。

このエラーは、ポート 80 とポート でリッスンしている nginx 構成がある場合に発生する可能性があります[::]: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

于 2013-02-26T23:52:47.663 に答える
45

今までになかった問題を見つけました。

削除する必要がありました/etc/nginx/sites-available/default。それからそれは働いた。

この削除により、シンボリックリンクのみが削除されます。バックアップとして、デフォルトのファイルは次の場所にあります。 /etc/nginx/sites-enabled/default

私のconfはにありました/etc/nginx/default

于 2013-02-24T12:47:22.490 に答える
28

私も同じエラーを受けていました。

nginx: [emerg] bind() to [::]:80 failed (98: アドレスは既に使用されています)

そして、ブラウザにlocalhostを入力すると、取得していました

できます!

これは、このサーバーのデフォルトの Web ページです。

Web サーバー ソフトウェアは実行されていますが、コンテンツはまだ追加されていません。nginx ウェルカム ページの代わりに、apache2 が同じポートで実行されています。

  1. apache2 のports.confファイルを見つけます

    sudo /etc/apache2/ports.conf
    
  2. それ以外のポートを変更して80、私はそれを次のようにします70

  3. ファイルを保存します

  4. システムを再起動します

ブラウザに localhost を入力すると、nginx のウェルカム ページが表示されます。

于 2013-05-29T05:37:04.920 に答える
9

実行して解決しました

sudo killall apache2

sudo fuser -k 443/tcp

最後に

sudo service nginx start
于 2021-03-19T11:06:38.383 に答える
7

私はletsencrypt(certbot)とnginxで同じ問題を抱えていました。

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

このエラーにはまだ解決策がありません

そのため、更新用の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()
于 2018-06-11T15:12:19.733 に答える
4

スーパーバイザーを使用して、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はフォアグラウンドに留まり、スーパーバイザーは別のインスタンスの実行を停止しました.

于 2019-07-24T10:44:42.030 に答える