Nginx Error: [::1]:80 failed: Address family not supported by protocol [Solved]

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[5069]: nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
Feb 19 23:46:27 nginx[5069]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 19 23:46:27 systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 19 23:46:27 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed

Nginx Error Address family not supported by protocol

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

vim /etc/nginx/sites-enabled/default

Step 2: Comment the below line:

listen [::]:80 default_server;

Now restart the nginx service and it should work.

Related Content
vps germany
Disclaimer: The content published in this article is the views of the author only. Techglimpse does not gurantee accuracy, completness or validity. If you believe the content on this post violates your copyright, please send us a mail for removal. Read more.