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.

If I run:

$ sudo service nginx status
* nginx is not running

Then I run:

$ sudo service nginx start
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
...
nginx: [emerg] still could not bind()

So I kill it:

sudo fuser -k 80/tcp

So I try to start Nginx again:

$ sudo service nginx start
Starting nginx: nginx.

Should be running now, right?:

$ sudo service nginx status
* nginx is not running

I tried:

$ ps aux | grep nginx
root      1316  0.0  0.2  64988  1236 ?        Ss   14:37   0:00 nginx: master process /usr/sbin/nginx
nobody    1317  0.0  0.3  65408  1908 ?        S    14:37   0:00 nginx: worker process
myusername     1436  0.0  0.1   9388   876 pts/2    S+   14:40   0:00 grep nginx

When I visit the ip of the site. I get a 404 message with nginx/1.2.1 on the bottom. Which would seem to me that it is actually running. And I am blocking ip addresses in nginx.conf and those ip's are presently being blocked, I tested. So I am confused as to whether Nginx is running or not and how to take hold of this beast.
My end goal is to have Gunicorn running too. The weird thing is this was all working yesterday. Gunicorn and Nginx both with statuses of working.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

404 = no page found.

That means nginx is serving the request (alongs you got nothing else running on port 80). From the sounds of it, the server has started fine. Just create a index.htm file in your nginx directory root with "hello world" then you will see something.

share|improve this answer
    
Good point. It is running. But why does it say that it is not running? –  user974407 Feb 28 '13 at 16:01

Maybe you have apache running on the same port and nginx can't bind the address because is already in use.
To change the port for nginx, have a look at this reply on stackoverflow [1]http://stackoverflow.com/questions/10829402/how-to-start-nginx-via-different-portother-than-80

Here there is an example on my lapdog

marco@BeastFMM:~$ sudo service nginx start
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
nginx.
marco@BeastFMM:~$ sudo /etc/init.d/apache2 stop
sudo: unable to resolve host BeastFMM
 * Stopping web server apache2                                                                                                                                   apache2: apr_sockaddr_info_get() failed for BeastFMM
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 ... waiting                                                                                                                                              [ OK ]
marco@BeastFMM:~$ sudo service nginx start
Starting nginx: nginx.
marco@BeastFMM:~$ ps aux | grep nginx
root      7986  0.0  0.0  78976  1288 ?        Ss   17:07   0:00 nginx: master process /usr/sbin/nginx
www-data  7987  0.0  0.0  79316  1708 ?        S    17:07   0:00 nginx: worker process
www-data  7988  0.0  0.0  79316  1708 ?        S    17:07   0:00 nginx: worker process
www-data  7989  0.0  0.0  79316  1708 ?        S    17:07   0:00 nginx: worker process
www-data  7990  0.0  0.0  79316  1708 ?        S    17:07   0:00 nginx: worker process
share|improve this answer
    
Thanks. I do not have apache on this server though. But something else must be using port 80... your right. –  user974407 Mar 1 '13 at 0:19

Did you changed the location of the pid file? Normally when you start a service it checks whether its already running or not, does nothing if it is and starts it otherwise. So those bind errors you're getting shouldn't happened.

The default location vor nginx pid file with vinit is /var/run/nginx.pid.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.