I am getting this error when I try to start Apache in Ubuntu.
(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 have this in my ports.conf
NameVirtualHost *:80
Listen 80
This is my vhost file
<VirtualHost *:80>
ServerAdmin example@example.com
ServerName rails.server.com
# ServerAlias
DocumentRoot /var/www/sample_app/current/public
ErrorLog /var/www/sample_app/error.log
RailsEnv production
<Directory "/var/www/sample_app/current/public">
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
What am I missing?
It seems port 80 is already taken. Use another port or try
netstat
(grep
the result to select only the row with value 80 in it),ps
andkill
to see what application occupies the port and shut it down.pkill
the process (nginx?)Disable whatever virtualhost is binding to port 80 that you don't want to (nginx?). It's in /etc/nginx/sites-enabled or /etc/apache2/sites-enabled
When you restart or start your server via terminal you might have forgot to add sudo before the command.
Use
sudo /etc/init.d/apache2 reload
instead of/etc/init.d/apache2 reload
List of currently running services,
Find only specific services,
Did you notice above result PID (6399) running python.
Kill that service using following command,
Now services is completely stop, you can start again normally.
Extra command for finding running srrvices,
I got this error on a fresh install of Ubuntu 12.10 when starting apache2.
It's a bug in the apache2. It gets hung in the background. Here is my walkthrough to where the bugs might be in the software.
Here's the error I got:
Address already in Use? What could be using it? Check it out:
That means apache2 is preventing apache2 from starting. Bizarre. This will confirm:
Yes, in this case apache2 is running, I was trying to start apache2 a second time on the same port.
What confuses me is that
service
reports that apache2 is NOT running:And when you query apache2ctl for its status, it hangs.
So Ubuntu seems to be having trouble managing apache2 on bootup. Time to stop apache2:
A big clue! You try to stop apache2 and it lost the process id! So Ubuntu can't stop apache2 because it doesn't know where it is!
You would think a reboot would fix it, but it doesn't because apache2 starts on boot and hangs. The normal boot process for apache2 is not working right.
So How to fix it?
I was able to fix this by analyzing the
ps
command output. Notice that theps
command tells us that that process was started by "/etc/rc2.d/S91apache2 start".That is the offending program that needs a swift kick.
/etc/rc2.d/S91apache2
is the symbolic link used to start apache2 for you when the computer starts. For some reason it seems to be starting apache2 and then hangs. So we'll have to tell it to not do that.So go take a look at that
/etc/rc2.d/S91apache2
.It's a symbolic link that we don't want it to be there. Do this to prevent apache2 from starting on boot:
Reboot the computer to make sure apache2 doesn't start and hang. Ok good. Now you COULD put apache2 back the way it was, but that would make it fail again.
Instead, start the apache2 like this:
And the apache2 is back up and serving pages again. There seems to be some serious bugs with apache2/Ubuntu 12.10 that causes apache2 to start and hang. This is a workaround, I suppose the fix is to get newer versions of apache2 and Ubuntu and hope for the best.
sudo kill -9 -2321 (pid) Restart BT Done..... no need to make changes in conf. file.