I'm running on a server that has Apache on port 80. I also have nginx installed, and just one conf file in /etc/nginx/sites-enabled
which has listen 8888;
specified. This works perfectly fine.
Now, I added a second conf file for a different vhost within /etc/nginx/sites-enabled
, listening on port 7979. When I run sudo service nginx restart
, I get:
Restarting 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.
Nowhere in any file within /etc/nginx
is port 80 mentioned! And the only reason I used a different port (7979) is because if both vhosts had port 8888, one would simply redirect to the other, even though they have different server_name
values.
What's going on here?
do this and i'm sure you'll find the answer
Sometimes if you do something like delete the default vhost and then upgrade it re-installs it back and that uses port 80
So if nginx isn't using it find what is
That will list the any pid using port 80.. then you can grep for it
If you have a server block without a listen directive, Nginx will default to 80.
source: Server Fault: Nginx tries to run on port 80 but the configs have been removed