Centos 7 nginx cannot start with the system after binding IP, and displays bind() failed
PHPz
PHPz 2017-05-16 17:25:18
0
1
795

I specially created a new virtual machine for testing. The virtual machine has two IPs: a.a.a.a and b.b.b.b. I hope nginx will only listen to a.a.a.a:80
However, when the specified listening ip listen a.a.a.a:80; is set in the configuration file and the system is restarted, nginx will fail to start and report an error Starting nginx: [emerg]: bind() to a.a.a.a failed (99: Cannot assign requested address), but at this time, as long as you manually systemctl start nginx, it can start normally.
After removing the ip listen 80; in the configuration file and restarting the system, nginx can start normally.
Summarize:
After specifying the listening IP, the service cannot be automatically started with the system, but the service can be started manually and used normally.
If you do not specify the listening IP, the service will be automatically started with the system and it will work normally.

How to solve this situation?

For temporary solutions, see the comments on this post (not expanded by default)
The speculated reason is that nginx needs to detect the IP to bind, but the system does not return a value when detecting or the detection time is too fast, causing the system to not allow binding. Please wait for the master to add for details

PHPz
PHPz

学习是最好的投资!

reply all(1)
習慣沉默

Check whether the user who starts nginx is the root user. By default, port 80 can only be occupied by root. You must also modify the relevant configuration to allow ordinary users to occupy port 80.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template