Question

Ubuntu Keeps Needing Restart

We have a Zend/PHP app hosted on a droplet. Recently the app has been crashing on average every six hours; the browser won’t connect. We haven’t really made any changes to the droplet/server or the app. Restarting Ubuntu brings it right back up, but I’m trying to get to the root cause here. This is in /var/apache2/error.log right before the crash every time:

[Sat Sep 21 07:11:29.055079 2024] [mpm_prefork:notice] [pid 1034] AH00171: Graceful restart requested, doing restart
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
[Sat Sep 21 07:11:29.071225 2024] [mpm_prefork:alert] [pid 1034] no listening sockets available, shutting down
[Sat Sep 21 07:11:29.071231 2024] [:emerg] [pid 1034] AH00019: Unable to open logs, exiting
[Sat Sep 21 07:11:33.376569 2024] [core:warn] [pid 28319] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Sat Sep 21 07:11:33.380530 2024] [mpm_prefork:notice] [pid 28319] AH00163: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sat Sep 21 07:11:33.380572 2024] [core:notice] [pid 28319] AH00094: Command line: '/usr/sbin/apache2'

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I’m not sure it’s a memory issue; we’ve upgraded the darn thing to a near supercomputer a while back! And it started all of a sudden. Who knows though.

Running through

`sudo systemctl status apache2.service -l --no-pager`
`sudo ss -4 -tlnp | grep 80`
`sudo ss -6 -tlnp |grep 80`
`sudo ps -p 40`

showed that multiple instances of NGINX were running. I wasn’t sure if we use that or Apache so I stopped Apache and the site went down. Therefore I decided to just say farewell to everything NGINX. I ran:

sudo systemctl disable nginx

which disables NGINX from starting on boot and we haven’t had an issue since.

Probably not the best solution but it did fix it!

alexdo
Site Moderator
Site Moderator badge
September 26, 2024

Heya,

The first error is likely related to an unclean shutdown whichs leaves orphaned Apache processes, causing the error - (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80

I’ll recommend to examine the logs if the droplet us running out of memory. Usually there will be references in /var/log/messages indicating that a process was killed - oom or out of memory

What I would usually do if I’m getting that error on a Droplet with 1GB of RAM, is to add swap space, that way you would have some extra buffer in case that your RAM is fully exhausted. This step usually benefits a lot a smaller droplet.

You can follow the steps on how to do that here:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-22-04

Hope that this helps!

Hey Topher,

The could not bind to address 0.0.0.0:80 error is making me think that you might either have multiple Apache instances running or possibly another web server like Nginx also installed.

First, check if there are multiple Apache processes running at the same time. Run the following command to list all Apache processes:

ps aux | grep apache2

If you see more than one Apache master process (with different PIDs), that’s a problem. You can try killing all Apache processes and restarting Apache cleanly:

sudo killall apache2
sudo systemctl start apache2

Also check if Nginx is running on that port by any chance:

netstat -plant

Basically, you can monitor what’s using port 80 to catch any conflicts:

sudo lsof -i :80

This will show you any processes bound to port 80. If you see multiple Apache processes or another service using the port, that’s likely causing the problem.

Since the log mentions “graceful restart requested,” something might be triggering it. Check for cron jobs or scheduled tasks that could be causing this:

sudo crontab -l

If there’s a cron job or something similar restarting Apache, either remove it or modify it to prevent these frequent restarts.

If there are no cron jobs that might be causing this, it’s possible the server is running out of resources (CPU, RAM), which could trigger unclean shutdowns. Check system logs for any signs of resource exhaustion:

sudo dmesg | grep -i oom

If you see any “Out of Memory” (OOM) errors, you may need to optimize your app’s resource usage or resize your Droplet to handle the load.

Or alternatively, check your DigitalOcean monitoring graphs:

https://docs.digitalocean.com/products/monitoring/

You might need to just upgrade your server and add more RAM and CPU:

https://docs.digitalocean.com/products/droplets/how-to/resize/

Let me know if you need more help or if this resolves it! 🚀

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more