Page 1 of 1

Nginx fails to start after reboot

Posted: Mon Jan 11, 2016 3:43 pm
by stevetoza
Clean install of Vesta, nginx + php-fpm version. When I reboot the server nginx doesn't start getting the below in the nginx log. If I press the start button in the vesta control panel nginx then starts.

Code: Select all

2016/01/11 10:16:14 [emerg] 109#0: bind() to 111.111.111.111:80 failed (99: Cannot assign requested address)
2016/01/11 10:20:45 [emerg] 130#0: bind() to 111.111.111.111:80 failed (99: Cannot assign requested address)
2016/01/11 10:25:08 [emerg] 130#0: bind() to 111.111.111.111:80 failed (99: Cannot assign requested address)
2016/01/11 15:30:48 [emerg] 118#0: bind() to 111.111.111.111:80 failed (99: Cannot assign requested address)
Been no IP adress changes as its a clean server.

OS CentOS 7.2

Thanks

Re: Nginx fails to start after reboot

Posted: Sun Jan 17, 2016 12:14 am
by BBuchanan1013
I would use the "fuser" command to find out what is using ports 80 and 443, then proceed from there.

Code: Select all

#  fuser 80/tcp
80/tcp:               2850 12763 15537 18030 30044 32226
The return from fuser shows that processes with pids 2850 12763 15537 18030 30044 32226 are using port 80.

Code: Select all

#  ps aux | grep 2850 | grep -v grep
root      2850  0.0  0.4 318772 30428 ?        Ssl  Oct22   0:03 /usr/sbin/httpd
So, in this case it is httpd process listening on port 80. Look for children:

Code: Select all

 #  pgrep httpd
2850
12763
15537
18030
30044
32226
So those are all instances of httpd.
Mind you, this was written for httpd and not nginx, however, the principle is still the same. Nginx can't start on port 80 because something is using it.

Re: Nginx fails to start after reboot

Posted: Mon Jan 18, 2016 9:11 am
by grenadecx
As @BBuchanan1013 said, something is using port 80.

If you used Ubuntu (14.04 up to date), there's some bug with the install because it will installa apache server as well, even if you did pick nginx+fpm. At least that's what happened with me. Might be because of some other package that vesta uses that have apache as dependency.

Re: Nginx fails to start after reboot

Posted: Mon Jan 18, 2016 9:13 am
by Elizine
Try the below code -

Code: Select all

# sudo update-rc.d nginx defaults
Or:

Code: Select all

# sudo apt-get install chkconfig

Code: Select all

# sudo chkconfig nginx on

Re: Nginx fails to start after reboot

Posted: Mon Mar 07, 2016 3:43 pm
by stevetoza
chkconfig nginx on - This is already set as nginx is trying to start but not able to.

pgrep - Nothing else is running on the port 80 or 443. Seems to be an issue only on OpenVZ vps's any dedicated servers I have vesta on nginx starts ok.

Thanks

Re: Nginx fails to start after reboot

Posted: Fri May 06, 2016 6:22 pm
by lakis21
Hi I found this solutions on searching:

Code: Select all

nano /usr/lib/systemd/system/nginx.service
replace the first 4 lines:

Code: Select all

[Unit]
Description=Startup script for nginx service
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
It works on my 2 VPS. :)