Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I set up an EC2 instance using Ubuntu 13.10 64 bit. The instance has a security group with http 80 open to 0.0.0.0/0.

I installed nginx, restarted the server, and confirmed that nginx was running:

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

and . . .

sudo service nginx status
 * nginx is running

Okay cool so then I tried to test it . . .

curl localhost
curl: (7) Failed connect to localhost:80; Connection refused

Confirmed the EC2 Security Group was open: 80 (HTTP) 0.0.0.0/0

Installed Django, fired up a test at port 8000. That worked. Lot's of head scratching ensued. Then I decided to look at the ports:

netstat -an | grep ":80" 
tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN   

Odd. So I try -- netstat -an | grep "nginx" -- and that comes back empty. Even after I restart nginx.

So now I am lost. The system tells me nginx is running but it is not. I can successfully start it, stop it, restart it and 'sudo nginx status' will report it as running. But it doesn't show up on a netstat and I cannot curl or telnet the service. If EC2 isn't blocking port 80, I figure Ubuntu might be? But it seems like nginx should fail to start and report an error. How do I resolve this issue?

** Solved - Sort Of **

Still not sure what was going on. A simple install of nginx, with the default nginx.conf should bind to 80 and accept requests. I decided to created a second instance; this time I went with the 12.04 LTS instance. I installed nginx, fired it up, it bound to Port 80, and when I tested with curl example.com and it worked. So I will terminate my old instance and go with the new one for now. But I'm bothered by the 13.10 effort so I may try that again later tonight.

share|improve this question
    
Is localhost in your hosts file ? try whit 127.0.0.1 or whit public ip to test it. And what about your vhost ? is listen on port 80 ?, have you a vhost file ? –  Skamasle Nov 22 '13 at 16:37
    
The test netstat -an | grep "nginx" is pointless, as those flags to netstat don't return the process name anyway. Try netstat -apn|grep nginx, which will need to be run with privilege. –  MadHatter Nov 22 '13 at 16:39
    
@MadHatter, that shows eight entries: unix 3 [ ] STREAM CONNECTED 11478 1849/nginx unix 3 [ ] STREAM CONNECTED 11471 1849/nginx –  eezis Nov 22 '13 at 16:49
    
@Skamasle, there is an /etc/hosts file the first entry is: 127.0.0.1 localhost I do not have an /etc/vhost file –  eezis Nov 22 '13 at 16:52
2  
Please post your nginx.conf. Right now there is no indication that you configured nginx to listen on any port at all. –  84104 Nov 22 '13 at 17:19
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.