apache server not restarting in ubuntu 14.04 - apache

When I am trying to restart the apache2 services with sudo service apache2 restart command, I am getting this error.
(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 no listening sockets available,
shutting down AH00015: Unable to open logs Action 'start' failed. The
Apache error log may have more information.
So I added ServerName localhost in my apache2.conf file and then tried to restart the apache2 service. I am getting the same above error.
Please help.

There are two reasons why this problem exists:
1. Multiple ‘Listen’ Directive Entries Existing in Configuration Files. (Solution below)
Hit grep Listen /etc/apache2/ports.conf
Check if you are getting something like:
Listen 80
Listen 81
Listen 80
Listen 443
Listen 443
The error log could not bind to address 0.0.0.0:80 mentions its an issue with the port 80. Hence edit the file and remove the duplicate.
2. Another Process is Already Using Port 80
Hit : fuser -n tcp 80 along with ps aux | grep PID or hit
ss -plnt sport eq :80
and kill the processes.

You probably have a process that's still using it. You can do
pidof apache2
The last pid in the list is the main process you can kill.
or you can do
netstat -anp | grep :80 | grep -i listen
Then on the right hand side of the line, that it outputs you'll see the PID.
or you can do
lsof -i :80
Then the top apache process is the one you'll want to kill. Which is the number in the 2nd column output.
Then whenver you have the main pid from one of these commands use this.
kill -9 <pid> e.g. kill -9 12345

Related

apache not working httpd lightsail instance lamp bitnami

When I restart my instance in lightsail I get the "apache server not running". When I run the command
sudo /opt/bitnami/ctlscript.sh restart
I get this error:
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : apache not running
/opt/bitnami/php/scripts/ctl.sh : php-fpm stopped
/opt/bitnami/mysql/scripts/ctl.sh : mysql stopped
/opt/bitnami/mysql/scripts/ctl.sh : mysql started at port 3306
/opt/bitnami/php/scripts/ctl.sh : php-fpm started
Syntax OK
(98)Address already in use: AH00073: make_sock: unable to listen for connections on address
[::]:443
(98)Address already in use: AH00073: make_sock: unable to listen for connections on address 0.0.0.0:443
no listening sockets available, shutting down
AH00015: Unable to open logs
/opt/bitnami/apache2/scripts/ctl.sh : httpd could not be started
I' m blocked, I don't know what can I do; all websites are down and I get the error ERR_SSL_PROTOCOL_ERROR when I want to redirect to all my websites.
sudo netstat -ltnp | grep ':80'
tcp6 0 0 :::80 :::* LISTEN 1584/httpd
sudo kill -9 1584
sudo /opt/bitnami/ctlscript.sh restart apache
Repeat the command until you kill all conflicting processes

Unable to start Apache - (98)Address already in use: AH00073

Recently decided to change my VM type on my Google Cloud account, but in the process of changing the VM it seems something has gone wrong as I'm now unable to start Apache as I keep getting the following error:
(98)Address already in use: AH00073: make_sock: unable to listen for connections on address [::]:80
(98)Address already in use: AH00073: make_sock: unable to listen for connections on address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
I have tried to do the following steps:
netstat -ltnp | grep :80
This would return the following:
tcp6 0 0 :::80 :::* LISTEN 1047/apache2
Then run the following command:
sudo kill -9 1047
(1047 - pid no)
(the pid that appears on your particular instance.)
Restart Apache.
sudo service apache2 restart
But this doesn't help, i keep getting the same error. In fact if I run netstat right after killing the process, a new process with an incremental id of 1 pops up.
Also ran
grep Listen /etc/apache2/ports.conf
To see if there are multiple processes on the same port, that does not seem to be the case :-(
I'm stuck, help :-(
Mikael
Managed to sort this out in the end by changing the port for Apache, not sure what or why port 80 was taken, but I followed these steps which did the trick:
https://docs.bitnami.com/aws/apps/redmine/administration/configure-port/#http-port
Cheers,
Mika

Apache configured to listen on port 80 only but instead listening on port 8080 as well

I was not able to use port 8080 because it was apparently already used.
In order to see which program was using it, I typed the following command in my terminal (on MacOS):
sudo lsof -n -i :8080
Here's the result:
httpd is also listening on port 80, which I found out by using the following command:
sudo lsof -n -i :80 | grep LISTEN
Here's the result:
So I went to find out what this "httpd"-process was. Apparently it is basically the web server installed on my machine. The web server installed on my machine is Apache2.
Given this fact I concluded that Apache2 was apparently configured to listen on port 80 AND on port 8080.
BUT: Here's the crazy thing: I went to the folder /etc/apache2 and opened the file "httpd.conf". In the file Apache is configured to listen on port 80 only !!!
Why the hell is it also listening on port 8080 ?!
How can I make it listen on port 80 only ?

Can't restart apache (98)Address already in use, even after I kill process

I'm unable to (re)start apache because port 80 is already in use:
[root#out-dev log]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using <ip> for ServerName
(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
[FAILED]
So I tried identifying the process which was using port 80:
[root#out-dev log]# netstat -npl | grep ':80'
tcp 0 0 :::80 :::* LISTEN 3840/httpd
It's httpd! That's odd to me because the service httpd is apparently not running:
[root#out-dev log]# service httpd status
httpd is stopped
Anyway, I tried killing the process, but as soon as I do, a new process appears, taking control of port 80. And all the while, service httpd status indicates that httpd is not running.
[root#out-dev log]# kill -9 3840
[root#out-dev log]# netstat -npl | grep ':80'
tcp 0 0 :::80 :::* LISTEN 3842/httpd

Starting apache fails (could not bind to address 0.0.0.0:80)

Update: Already fixed, it seems that one of VirtualHosts configurations files was wrong in sites-enabled.
I have Ubuntu 11.10
When I run the command to start apache2:
sudo /etc/init.d/apache2 start
I get the following error message:
Starting web server apache2
apache2: Could not reliably determine the server's fully qualified
domain name, using 127.0.1.1 for ServerName (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 Action 'start'
failed.
I run this command in order to get the process that is using the port 80:
sudo netstat -ltnp | grep ':80'
Which returns this output:
tcp6 0 0 :::80 :::* LISTEN 1176/
To know which process is I run this command:
ps -wlp1176
That returns:
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
5 D 33 1176 1 0 80 0 - 0 exit ? 00:00:00 apache2
But if I try to kill the process:
sudo kill -9 1176
It doesn't kill it, if I run again the netstat command still appears listening and apache start fails.
Any suggestions?
Worked for me running this command:
fuser -k -n tcp 80
It may be skype or nginx using the port 80.
Try shutting down skype, or running: sudo /etc/init.d/nginx stop
I had the same error, and just want to confirm that running
sudo netstat -ltnp | grep ':80'
helped me indicate that Hiawatha webserver was in the way of Apache2.
Removing Hiawatha fixed the issue (sudo dpkg --purge hiawatha).
Ubuntu 12.04.2 server.
I had the same problem
For me, apache was already running but it was running the wrong way.
Killing processes didnt work because a daemon kept reinstantiating it.
apachectl stop
resolved the issue.
use either
sudo killall httpd
or
sudo killall apache2
check if some one using the 80 port
sudo netstat -tulpn| grep :80
The restart
sudo service httpd start
then restart the server.It took me a whole day to understand the issue
Try this, it works for me…
sudo netstat -ltnp | grep ':80'
This would return the following:
tcp6 0 0 :::80 :::* LISTEN 1047/apache2
Then
sudo kill -9 1047
Then I was able to restart Apache and everything was working fine.
Go to device manager, select “show hidden devices” from menu/view, go to “Non-Plug and Play Driver”/HTTP, double click it to disable it (and disable or manual some services depended on it).
Reboot and enjoy!
This will happen because of repeated installation of apache or port is using by another service
sudo lsof -i | grep "httpd"
You will find process id and listening port of service. Then check
cd /proc/(process id of http)
Then kill that process using command
kill -9 pid
now
sudo netstat -nltp
again kill the process
syntax:-
kill -9 pid
and now start apache
sudo ./apachectl start
It look like other process is using port 80.
$ netstat -anp | grep
eg. $ netstat -anp | grep 80
by above you get process name, if you want to use port then you need to stop the process or change the port
What I would do is simply check if the following is set in your /etc/apache2/sites-available/your-domain-name.com.conf
SSLEngine on
SSLCertificateFile /your/path/to/your-domain.com.crt
SSLCertificateKeyFile /your/path/to/your-domain.com.key
SSLCACertificateFile /your/path/to/your-domain.com.ca-bundle
and there aren't any mistyped directories or anything else that would not supposed to be in your .conf file. It did the trick for me as re-starting and killing the processes did not help at all. It did not start anyway.
I fixed it by using below procedure.
Run below command as root user.
root# ps aux |grep apache
It will show you Apache PID, just kill that PIDs and restart Apache Server.
You can only have listen PORTNUMBER in only one file of .conf. Do not put it in multiple files. Try it :)