# [SOLVED] Apache can't start

## c0vert

Hey guys,

I just isntalled apache2, then I edited the httpd.conf file to say the servername and port, localhost and 80 respectively.

Then I run

```

/etc/init.d/apache2 start

```

And I get the following:

```

laptop  /# /etc/init.d/apache2 start

 * Starting apache2 ...

(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                                                       [ !! ]

laptop /#

```

I'm not sure what these means or what I did wrong, can anyone help?  I may have tried to install apache a few months ago I can't remember, also I dont believe it is because apache is already running because I ran a stop for apache and apache2 and neither are started (apache can't even find file/directory) .  I thought that info might be useful because I saw someone ask when I googled the error.

Also I'm using this for reference:

http://gentoo-wiki.com/Apache2_Install

Thanks for any help!

Andrew

----------

## di1bert

Firstly check that your log files exist and that they're owned by your Apache user. They're usually

in /var/log/apache2.

It looks like something may already be listening on port 80 so do a netstat -nat | grep LIST | grep 80

or lsof -n -i :80 to see what's hogging the port...

HTH

-m

----------

## c0vert

Apparently nothing is.

```

laptop ~ # lsof -n -i:80

laptop ~ # netstat -nat | grep LIST | grep 80

laptop ~ # /etc/init.d/apache2 start

 * Starting apache2 ...

(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                                                       [ !! ]

laptop ~ # 

```

Any ideas?

----------

## c0vert

Solved by deleting the line:

```

Listen 80

```

Apparently a lot of people we're having this problem in last few days in #gentoo.  Hope this helps someone.

Andrew

----------

## RayDude

 *c0vert wrote:*   

> Solved by deleting the line:
> 
> ```
> 
> Listen 80
> ...

 

Ironically I solved the exact same problem by adding Listen 80 to my default vhost.

I couldn't find listen 80 anywhere in my config files and remembered having this problem before...

Thanks for the inspiration.

Raydude

----------

## c0vert

That is weird, because I don't have listen 80 anywhere in my config file either, so I added it, and it didn't work, took it out, and it worked.

So I figured that in some other file or setting it was automatically set.  Interesting though.

----------

## cjubon

In newer apache versions (since 2.2.6, if I remember well), the "Listen 80" default directive is no longer in /etc/apache2/httpd.conf, but in /etc/apache2/vhosts.d/00_default_vhost.conf, and people that do not have a virtual hosts setup are not yet used to take the files in that directory into consideration  :Wink: .

There is an explanation of the whole issue on the apache wiki: http://wiki.apache.org/httpd/CommonMisconfigurations, 1.1.4., Using the same Listen and/or NameVirtualHost multiple times

Cheers.

----------

## stuorguk

I have spent half the day on this.   :Evil or Very Mad: 

```

# apache2

no listening sockets available, shutting down

Unable to open logs

```

I removed Listen 80 from the default Vhost.  And put it back again, several times.

No other instances of Listen 80.

Nothing is blocking the port that I can see.   :Confused: 

----------

## stuorguk

I got apache working, by adding Listen 80, outside of the vhost default.

It was inside the default vhost but that never actually ran, so i put it outside of that, and apache worked again... almost.  PHP is now goosed.   :Rolling Eyes: 

----------

## richard.scott

I fixed this error on my system as I had a typo in /etc/conf.d/apache2

I'd got APACHE_OPTS rather than APACHE2_OPTS!

This then meant that the DEFAULT_VHOST stuff wasn't being loaded and therefore the "Listen 80" configuration wasn't being read.

doh!

----------

## col

I commented out the listen line from :

vhosts.d/00_default_vhost.conf

and the problem went away as well

----------

