EC2 Ubuntu-nginx: [emerg]绑定()到0.0.0.0:80失败(98:未知错误)。

3

运行sudo nginx命令后,我遇到了以下错误:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] still could not bind()

以下是我在AWS EC2上的安全设置: enter image description here 在我的Django项目中,我为nginx创建了一个配置文件:(nginx.conf) (我还使用uwsgi作为第二个Web服务器,它正在正常工作)
# the upstream components nginx needs to connect to
upstream dcohort {
        server unix:///tmp/dcohort.sock;
}

server {
        listen               80;
        listen               [::]:80;
        server_name          *.amazonaws.com;

        access_log off;
        error_log  /home/ubuntu/dcohort/logs/nginx_error.log;

        location / {
                include     /etc/nginx/uwsgi_params;
                uwsgi_pass  dcohort;
        }
}

然后将配置导入到/etc/nginx/nginx.conf
http {
        include /home/ubuntu/dcohort/config/nginx.conf;
        # ...
}

看到同样的问题,真是让人烦恼。我也在使用nginx+Django。之前我的设置一切正常,但是在停止旧的EC2机器并创建新的机器后,nginx无法重新启动,letsencrypt certbot因此失败了证书验证。很可能是配置出了问题... - alexakarpov
在这里也出现了同样的错误,有人找到解决办法吗? - undefined
2个回答

0

我也遇到了同样的问题,但我正在使用nodejs。

问题是因为nginx无法读取已经在端口80上运行的应用程序。

请确保您的应用程序在服务器上运行良好。


0
你有检查过/etc/nginx/sites-enabled吗?它包含了指向sites-available的链接。通常这种错误是由于你的配置文件冲突引起的,比如在不同的配置文件中多次使用了端口80,你应该移除或更新其中一个端口。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接