Nginx Error: [::1]:80 failed: Address family not supported by protocol [Solved]
- Tuesday, February 21, 2017 By Ramya Santhosh
Question: I have installed Nginx on a Ubuntu Xenial machine through apt-get. However the service failed to start with an error message as “Address family not supported by protocol“. Below is the complete nginx error message:
-- Unit nginx.service has begun starting up. Feb 19 23:46:27 nginx: nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol) Feb 19 23:46:27 nginx: nginx: configuration file /etc/nginx/nginx.conf test failed Feb 19 23:46:27 systemd: nginx.service: Control process exited, code=exited status=1 Feb 19 23:46:27 systemd: Failed to start A high performance web server and a reverse proxy server. -- Subject: Unit nginx.service has failed
Please help me to solve the issue – Karan.
How to fix Nginx error: Address family not supported by protocol
Solution: The error message indicates that the service is trying to start on IPv6 address “[::]:80” and failed due to unsupported address family. It means, the machine does not have an IPv6 address set. All you need to do is, simply edit the Ngnix configuration file to listen on IPv4 address as shown below.
Step 1: Open /etc/nginx/sites-enabled/default
Step 2: Comment the below line:
listen [::]:80 default_server;
Now restart the nginx service and it should work.