Nginx on-the-fly config reload leads to errors

configurationnginx

I tried to run a "nginx -c /etc/nginx/nginx.conf" but I got:

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()
[Exit 1]

Then I run a

 fuser -k 80/tcp ; service nginx restart.

I tried again with "nginx -c /etc/nginx/nginx.conf" but still the same error "[emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)"

Why is this happening?

Best Answer

This is not how you reload nginx.
What you are trying is starting nginx again, -c just specifies the configuration file it should use.
Use service nginx reload or /etc/init.d/nginx reload to reload it.

Related Topic