Andy E
Andy E

Reputation: 538

nginx starting but isn't listening on port 80

I have an ubuntu server 14.04 VPS that currently has apache2 serving up a static website. I am switching over to nginx to serve up a couple of nodejs sites.

I installed nginx

$ nginx -v
nginx version: nginx/1.4.6 (Ubuntu)

And am using the default config

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

I confirm apache2 isn't running causing problems

$ sudo service apache2 status
 * apache2 is not running

I start nginx and confirm it's status

$ sudo service nginx status
 * nginx is running

But yet hitting the sudo netstat -natp and sudo fuser 80/tcp all brought up nothing.

I have my site configured in /etc/nginx/sites-available/mydomain.tld and then linked to sites-enabled.

Still nothing.

Upvotes: 3

Views: 4330

Answers (1)

Andy E
Andy E

Reputation: 538

In the process of writing the question and reproducing the steps I figured out what the problem was.

I had created and edited my sites-available server in /etc/nginx/sites-available/mysite.tld

Then to enable the site, I was in the directory /etc/nginx/ when in my tired state created the link into the sites-enabled folder by running ln -s sites-available/mysite.tld sites-enabled/mysite.tld.

It wasn't until this morning that I realized I had created a bad link when I couldn't vim into the sites-enabled linked version.

Doing an rm on the bad link and then using absolute paths for the whole thing ln -s /etc/nginx/sites-available/mysite.tld /etc/nginx/sites-enabled/mysite.tld then a subsequent restart of nginx now shows it listening on port 80 as expected.

tl-dr; sometimes it's best to just go to bed and look at it in the morning

Upvotes: 3

Related Questions