This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12629|Reply: 0

[Web] Nginx self-startup failed

[Copy link]
Posted on 5/30/2015 11:46:28 PM | | |

Linode has been upgraded again~ But because the old machine in the Japanese computer room will take a few weeks to upgrade, I can't wait, so I opened a new machine, planning to move home, and by the way, sweep away the unnecessary garbage on the server.

The new machine uses the lnmp one-click installation script I wrote myself (in fact, most of the code is found online = =##), and after making the script on DigitalOcean, I put it on Linode to install. There was no problem with installation and moving, but as soon as it was restarted after installation, there was a problem.


After restarting, it stands to reason that Nginx should start automatically, but after waiting for a long time, the website still cannot be accessed. Log in to SSH and execute:

service nginx start

Launch Nginx manually, and the website will be accessible in no time. The self-starting script is fine, and there is no problem with manual starting, why does nginx just not start?

Looking through the logs, I found a line like this:

2014/05/02 17:02:28 [emerg] 2912#0: bind() to [2400:8900::f03c:91ff:fe6e:5889]:80 failed (99: Cannot assign requested address)

It feels like when starting Nginx, ipv6 has not been initialized, so the startup failed. When I log in to SSH and manually start Nginx, ipv6 has already been initialized, so it can start normally.

Probably guessed the reason, how to solve it? After a long day of Google, I found a similar problem and solution on ServerFault, and I will record it here.

Insert in /etc/sysctl.conf:
  1. sysctl -w net.ipv6.conf.eth0.dad_transmits=0
Copy code
Or:

Add a line in /etc/network/interfaces:
  1. post-up while ip -6 addr show tentative | grep . > /dev/null ; do sleep 1 ; done
Copy code
I use the latter method to solve the problem.




Previous:About Discuz! (X3.1) How to enable https encryption
Next:Houpu Cup Participating Projects
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com