Nginx duplicate listen options for [::]:80 error

I'm creating an answer out of my earlier comment.

Please post the error message (nginx -t output) as it could contain some useful insight.

What nginx version are you running? Option ipv6only=on might not be needed anymore and on the contrary potentially create issues. I have this in my server block and it runs fine:

listen 80;
listen [::]:80;

Do you have any other server blocks you didn't post that might possibly conflict with eachother?


Explanation: let's read the current (1.13) nginx documentation:

ipv6only=on|off
this parameter (0.7.42) determines (via the IPV6_V6ONLY socket option) whether an IPv6 socket listening on a wildcard address [::] will accept only IPv6 connections or both IPv6 and IPv4 connections. This parameter is turned on by default. It can only be set once on start.

This parameter is turned on by default means that you should not use ipv6only=on. It does not do any good and can potentially create problems (see next point).

It can only be set once means that if you have it more than once anywhere in your configuration (such as in different server blocks), it will throw an error: nginx: [emerg] duplicate listen options for [::]:80.