0

We do frequent deployments using udeploy and there is a last step there to automatically restart apace http server using sudo ./apachectl -k restart. But sometimes the server fails to restart with below error:-

(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

Please note not all the times only sometimes. I verified everything with no duplicate Listen directives for port 80 in httpd conf files, no password prompt issues in ssl key files. I don't have root access to server so can't actually verify if there are any other processes that bind port 80 before main apache server starts. But is there anything else that could be causing the issue. Any help or suggestions here would be greatly appreciated.

Cheers,

Ashley

Ashley
  • 1,447
  • 3
  • 26
  • 52
  • What does your script do in its entirety? – covener Aug 31 '16 at 02:27
  • The script is just a plain simple one:- sudo ./apachectl -k restart. But sometimes this restart fails as described in the question. So i guess normal restart might be too fast and then when it attempts to start after stop, the error comes into picture because server might not have actually stopped and might be still using that port which it is bound to. i don't think there is some other process that binds to the port once apache server is restarted. Any thoughts? – Ashley Aug 31 '16 at 03:28

1 Answers1

0

Not sure of the timing, but perhaps add a second attempt to start when there is a failure and that might allow for enough time to free any resources which might be in use.

  • While this might be a valuable hint to solve the problem, an answer really needs to demonstrate the solution. Please [edit] to provide example code to show what you mean. Alternatively, consider waiting until you have earnt enough reputation to write this as a comment instead. – Toby Speight Aug 31 '16 at 22:11
  • I mean its automated deployment, so we should really not need to go into the server and manually restart it. I am just looking for something that i can include in my script that should allow the server restart under maximum circumstances – Ashley Sep 01 '16 at 01:35
  • Well is there a way i can write a script that automatically tries to restart server as i addressed above and based on whether it has actually restarted or not (that would mean restart exit code as 1 if not restarted), tries to find out if any process has held up port 80 and tries to kill that process and reattempts to start server. – Ashley Sep 01 '16 at 15:14