nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)

nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)

问题:

启动nginx报错:

解决:

1、编辑 vim /etc/nginx/sites-enabled/default

2、注释掉以下行:listen [::]:80 default_server;

3、重启nginx即可

原因:

ipv6引起的,从错误消息看来,您的服务器上禁用了ipv6。 编辑nginx的默认服务器配置,并将其更改为仅监听ipv4或 干脆启用ipv6。