All of a sudden I am getting the below nginx error
* Restarting nginx
* Stopping nginx nginx
...done.
* Starting nginx nginx
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
...done.
...done.
If I run
lsof -i :80 or sudo fuser -k 80/tcp
I get nothing. Nothing on port 80
Then I run the below:
sudo netstat -pan | grep ":80"
tcp 0 0 127.0.0.1:8070 0.0.0.0:* LISTEN 15056/uwsgi
tcp 0 0 10.170.35.97:39567 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39564 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39584 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39566 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39571 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39580 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39562 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39582 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39586 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39575 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39579 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39560 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39587 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39591 10.158.58.13:8080 TIME_WAIT -
tcp 0 0 10.170.35.97:39589 10.158.58.13:8080 TIME_WAIT -
I am stumped.
How to a debug?
I am using uwsgi with a
proxy pass on port 8070. uwsgi is running. Nginx is not. I am using ubuntu 12.4
Below are the relevant portions of my nginx conf file
upstream uwsgi_frontend {
server 127.0.0.1:8070;
}
server {
listen 80;
server_name 127.0.0.1;
location = /favicon.ico {
log_not_found off;
}
location / {
include uwsgi_params;
uwsgi_buffering off;
uwsgi_pass 127.0.0.1:8070;
}
}
Here is how I install nginx on ubuntu 12.04
nginx=stable;add-apt-repository ppa:nginx/$nginx;
apt-get update
apt get install nginx-full
If problem persists after trying any of the above solutions, Restart your server once. It worked for me :)
My case is different, I had to kill running Nginx to restart it.
Instead of
I had to use:
i fixed this by running
sudo apachectl stop
- turns out apache was running in the background and prevented nginx from starting on the desired port.On ubuntu run
sudo /etc/init.d/apache2 stop
I met similar problem. the log is like below
The last
[emerg]
shows thatduplicate listen options for [::]:80
which means that there are more than one nginx block file containing[::]:80
.My solution is to remove one of the
[::]:80
settingP.S. you probably have default block file. My advice is to keep this file as default server for port 80. and remove
[::]:80
from other block filesI had several *.save files (emergency dumps from nano) from different NGINX config files in my sites-avilable dir. Once I deleted these .save files, NGINX restarted fine. I assumed these were harmless since there were no corresponding symlinks, but I guess I was wrong.
First change apache listen port 80 to 8080 apache in /etc/apache2/ports.conf include
or
then add nginx as reverse proxy server that will listen apache port
After changes restart nginx server
Now all traffic will be handled by nginx server and send all dynamic request to apache and static conten is served by nginx server.
For advance configuration like cache :
https://www.linode.com/docs/web-servers/nginx/slightly-more-advanced-configurations-for-nginx/#basic-nginx-caching