By alysiap
Hi,
I’m currently creating a new droplet where a Node.js app will live on a subdomain. I setup the droplet using Ubuntu 18.04, installed Nginx and while configuring the subdomain in the “/etc/nginx/sites-available/sub.example.com” and received an error below when running the command “sudo nginx -t”:
nginx: [emerg] unknown directive “listen[::]:80” in /etc/nginx/sites-enabled/example.com:3 nginx: configuration file /etc/nginx/nginx.conf test failed
I’m not sure why I’m receiving this error, this is my first time building a droplet and am a front-end developer who knows very little about back-end processes.
Also, when I found a forum talking about this error, found and ran a command to list off all sites enables in nginx and this is what I have:
/etc/nginx/sites-enabled/sub.example.com: listen 80;
/etc/nginx/sites-enabled/sub.example.com: listen [::]:80;
/etc/nginx/sites-enabled/default: listen 80 default_server;
/etc/nginx/sites-enabled/default: listen [::]:80 default_server;
/etc/nginx/sites-enabled/default: # listen 443 ssl default_server;
/etc/nginx/sites-enabled/default: # listen [::]:443 ssl default_server;
/etc/nginx/sites-enabled/default:# listen 80;
/etc/nginx/sites-enabled/default:# listen [::]:80;
/etc/nginx/sites-enabled/example.com: listen 80;
/etc/nginx/sites-enabled/example.com: listen[::]:80;
Hope this helps, I’m 110% lost on what to do and how to proceed so any helpful tips and suggestions is greatly appreciated :) Thanks!
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!
Hello,
Can you please share the exact Nginx Server Block that you are using? I could then try to advise you further.
But usually what I would use as a Nginx Server Block is something like this:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name your_sub_domain_here;
location / {
try_files $uri $uri/ =404;
}
}
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.