Question

error duplicate listen options for [::]:443 when trying to add a subdomain to my nginx setup

I followed [this DigitalOcean guide on how to setup Nginx] (https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04)on an Ubuntu 18.04 droplet. I set up my domain’s nameservers to point to Cloudflare’s and then based on what I had read previously my understanding that to add a subdomain (blog.faizanjamil.dev in this case) I could simply add a file titled (blog.faizanjamil.dev) to the /etc/nginx/sites-available (and symlink that file with /etc/nginx/sites-enabled) Keep in mind I am using Let’s Encrypt

However when I add that file and then try to enable that site, I get the following when running sudo nginx -t

nginx: configuration file /etc/nginx/nginx.conf test failed```

Now the blog.faizanjamil.dev config was created by copying the faizanjamil.dev config and modifying it slightly. With the blog subdomain not included in ``sites-enabled`` nginx produced no errors in the configs.
I have tried the same procedure to create the config for the subdomain twice, no luck. I have shown the below files to a buncha people who then suggested I try a couple different things like removing the ``default`` config from ``sites-enabled``, no luck.
So can anyone please help with this issue?
Also before I forget I intend to deploy Ghost on that blog subdomain

My nginx.conf, faizanjamil.dev config, default config, and blog.faizanjamil.dev configs are attached in the pastebin links below.

[Nginx.conf](https://pastebin.com/AkiMFanp)
[faizanjamil.dev config](https://pastebin.com/kG9r6LDm)
[default config](https://pastebin.com/3GJNmd89)
[blog.faizanjamil.dev config](https://pastebin.com/JDz29xeT)

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Ok so I looked at this guide and found this:

In this new file, we’re going to have to look at the listen directives again. If you left the default_server option enabled in the last file, you’ll have to remove it in this file. Furthermore, you’ll have to get rid of the ipv6only=on option, as it can only be specified once per address/port combination:```
So I removed the line in the blog.faizanjamil.dev config that contained the ``ipv6only=on`` option.

And it works now.

Please leave this up in case anyone else comes across this issue.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.