Apache2 and nginx not starting

When I restart Hestia panel apache2 and nginx don’t start automatically, I have to start them manually in the control panel.
I looked in the logs and apache has no errors, but nginx error reports: 2020/04/19 17:45:22 [emerg] 466#466: bind() to myip:80 failed (99: Cannot assign requested address)
I’m not sure if this is the reason apache2 and nginx don’t start automatically, just thought I’d add that info.
I’m using Debian 10 and the latest Hestia release. Any help is much appreciated.

Hmm, it looks like something else is blocking the port for nginx and apache2. Did you have installed hestia on a fresh server? I do not have any issues on my deb10 test system, the processes are starting fine after reboot.

If I had to guess, I would say there is some local problem around. Where do you run your server? Is it a vps?

Hi,

I did a clean install on a new Debian 10 VPS this evening (Nginx, PHP-FPM, MariaDB), and I noticed that Nginx is not starting when I reboot the machine.

I installed HestiaCP with:

bash hst-install.sh -a no -o no -v no -j no -k no -g no -x no -z no -c no -t no -q no -d yes

When clicking on the start icon it shows the following:

https://pasteboard.co/J4DIP6x.png

I’m confused as the Nginx service is enabled.

I tested this on a local VM with the same result.

I’m not sure what the issue is?

Any help would be appreciated :slight_smile:

Looks like something is sitting on port 80, can you check what it is? https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/

What happens if you try to manualy start it? systemctl start nginx

Maybe this is related with Apache2 and nginx not starting

systemctl start nginx works fine.

But after rebooting it is not running :frowning:

These are the listening ports before systemctl start nginx.

Hmm, could be similar: https://support.plesk.com/hc/en-us/articles/213908925-nginx-on-Plesk-for-Linux-server-does-not-start-automatically-after-reboot-99-Cannot-assign-requested-address

Do you have a static ip?

2 Likes

Yes I am using a VPS with static IP.

I’ll take a look at that article and report back.

Hi Guys, just merged both threads beacuse i think they are related.

I just did a fresh install with your install string @LoGiCa7 and can’t produce the issue here - nginx is starting properly after reboot. It was tested on a up to date debian10 with Hetzner Cloud.

Where do you run your vps? It looks like a local issue, maybe it starts to fast or the ip isnt ready yet.

this! nginx obviously tries to start before the network is up and the IP is not connected yet. seems a rare condition - did you install your deb10 from a template of your provider or from official ISO?

the plesk-thread @Raphael linked above holds some pointers about how to manage systemd so that nginx waits with starting for the network to be up…

1 Like

I am using Debian 10 on a Hetzner VPS installed from debian-10.3.0-amd64-netinst.iso. I’m experiencing the same issue with a local Debian 10 install on VMware.

Hmm, Hetzner Cloud/VPS provides finished images that you could install - exactly this combination I’ve tested successfully.

I’ve fixed the issue by adding “ExecStartPre=/bin/sleep 10” to /etc/systemd/system/multi-user.target.wants/nginx.service

From the article you linked to.

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/bin/sleep 10
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

Thanks for your help :slight_smile:

5 Likes

This fixed it for nginx, but apache still did not start.
I’ve now added it to /etc/systemd/system/multi-user.target.wants/apache2.service
Both services are now starting on reboot.

Thanks for the help @LoGiCa7 and everybody else.

I looked in the apache logs this morning and there is a load or errors and warns.

[php7:error] [pid 9851] [client 27.151.0.75:0]’/var/www/html/shell.php’ not found or unable to stat
[php7:error] [pid 9852] [client 27.151.0.75:0] script ‘/var/www/html/99.php’ not found or unable to stat

Ive added the log to pastebin if anybody wants a look.
https://pastebin.com/QT521jsV

This is a fresh install on a idle Kimsufi dedicated server. Nothing is being used on the server, no websites and Ive installed nothing.

2 Likes

Sounds like bots, scanning for exploits, you can ignore them.

2 Likes

I had the same problem. Apache and nginx didn’t start automatically after reboot. But i installed Docker before HestiaCP. My fault. Docker added new local ip. After I deleted docker IP from HestiaCP, Apache and Nginx started automatically properly.

Thanks HestiaCP developers for your work!

1 Like

Previous message not right. It was just a luck. I tried reboot few times. And nginx didn’t start again.

I tried this method. It works! Thank you.

10 seconds sleep is already a lot. 1 or 2 should be sufficient. however, we should probably look into this and correct the systemd target settings instead, to use the proper way for the services to wait for (all) network being available, before trying to start…

2 Likes

I had this issue start gain when upgrading to v1.2.3 and also with a clean install.

Not sure if this is the best place to post this, but just came across this issue on my end. I didnt before on a slower vps but it rears its head on my current vps that has a really fast CPU and network.

Changing
After=network.target

To
After=network-online.target

in both of these files
/etc/systemd/system/multi-user.target.wants/apache2.service
/etc/systemd/system/multi-user.target.wants/nginx.service

fixed the issue.

Not sure if this should be considered a bug but wanted to post for others that may come along.

1 Like