When provisioning with Bedrock-Ansible I was running into a problem where the first time I tried to reboot nginx on the provisioned box it would fail with a bind error in the main error log saying that the port was already busy:
bind() to 0.0.0.0:80 failed (98: Address already in use)
Changing line 30 in the Bedrock Ansible nginx template from
/var/run/nginx.pid to just
/run/nginx.pid has fixed the issue.
Does anyone have any ideas why this might be?
Is this locally and with Vagrant?
That error message is usually because something else is using port 80 to listen.
It happened both with Vagrant locally, and with Vagrant and aws. Nothing else is running on port 80, it’s nginx itself running.
So just to clarify, I provision with /var/run/nginx.pid and the problem happens, provision with /run/nginx.pid and it goes away. ie, I can restart nginx without any trouble. Also, it’s only the first restart that is a problem, subsequent service nginx restarts work fine. It’s a curiosity and I was just wondering if anyone else had run into something similar or had a simple explanation. I thought maybe something about installing nginx and it getting automatically started by upstart (ubuntu) and then the service module not having the right permissions or something, but I’m at a loss to explain it really.
Never seen this happen. How are you restarting Nginx? I doubt that’s it but just wondering.
vagrant ssh then
sudo service nginx restart
Yeah, not sure exactly how we missed until then. But it was a 14.04 issue specifically.
/run/nginx.pid is correct and should stay. Funny thing is someone else was troubleshooting this problem for our HHVM branch and found that solution. I completely forgot about this topic which would have been helpful.