# Apache hangs

## jcampbell

This is strange... I start apache and it works. I restart it and get this:

```
tiger ~ # /etc/init.d/apache2 start

 * Starting apache2 ...                                                                         [ ok ]

tiger ~ # /etc/init.d/apache2 stop

 * Stopping apache2 ...

httpd (no pid file) not running                                                                 [ ok ]

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

 * Starting apache2 ...

(98)Address already in use: make_sock: could not bind to address [::]:80

no listening sockets available, shutting down

Unable to open logs

tiger ~ # /etc/init.d/apache2 zap

 * Manually resetting apache2 to stopped state.

tiger ~ # killall -s SIGKILL apache2

tiger ~ # 
```

The apache server stays running even after the init script dies. There is no apache.pid in /var/run but the process continues to run. Best part is that no matter how many times I start apache after the initial failure, the server hangs when I try to browse any sites that it hosts. The only way I've been able to fix it is to reboot.

I don't recall ever having this problem before...Last edited by jcampbell on Sun Sep 25, 2005 5:31 am; edited 1 time in total

----------

## jcampbell

okay... more info... viewing apache's error_log:

```
[Sun Sep 25 01:16:39 2005] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Sun Sep 25 01:16:39 2005] [notice] Digest: generating secret for digest authentication ...
```

I commented out this line in httpd.conf:

```
LoadModule auth_digest_module            modules/mod_auth_digest.so
```

and it cured the problem. It's okay for a work-around, but why is this causing apache to hang?

Apparently, this has been an issue before? It's a different apache version... I have 2.0.54-r31

https://forums.gentoo.org/viewtopic-t-151105-highlight-authdigestmodule.html

----------

## gbpack

I'm still having this exact problem.  I tried the workaround but that didn't work either.  I posted this in IRC a little while ago but no one replied.  If anyone has any ideas .... it would be greatly appreciated.

----------

## Janne Pikkarainen

I had the same problem with Apache 1.3.x some years back, but I can't remember if I ever fixed it (in any other way than not using the mod_auth_digest).

Anyway, maybe this problem could be a classic "kernel runs out of entropy" problem? If your server runs mostly idle and mod_auth_digest gets its digest data from /dev/random, it could be that kernel is unable to generate random data fast enough. Check that with command cat /proc/sys/kernel/random/entropy_avail -- if it's 0, then your server has temporarily run out of entropy. 

In that case you may emerge rng-tools and run rngd, which generates some less perfect entropy.

----------

## gbpack

cat /proc/sys/kernel/random/entropy_avail says 4096.

----------

## gbpack

installed rng-tools and started it up.  Tried starting apache2 again and it still doesn't put a pid file in /var/run.  Apache says it started ok, but my home page won't load.  Error log says:

[Sun Sep 25 11:31:05 2005] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Sun Sep 25 11:31:07 2005] [notice] Digest: generating secret for digest authentication ...

[Sun Sep 25 11:31:07 2005] [notice] Digest: done

I have no idea what to do?

----------

## Troy

It's not just you.  Since the update, I can't restart apache  :Sad:   I have no entropy and no physical access to the system to create entropy.  I'd used MY_BUILTINS="--with-devrandom=/dev/urandom" emerge apache in the past to fix this.  It's not fixing it this time.  I added urandom to my USE flags as suggested by the apr-0.9.6 ebuild, rebuilt APR and apache2 with no success.  Not good...

----------

## taiger

I have the same problem

I have temporaly cammented: 

modules/mod_auth_digest.so

 :Question: 

----------

## chrismear

This might be some help. On one of my servers, it generates the secret instantly, so I never noticed this problem. But on another server, it takes about two minutes to generate the secret. Once it's done that, though, apache runs perfectly:

[Sat Oct 01 10:00:36 2005] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Sat Oct 01 10:00:36 2005] [notice] Digest: generating secret for digest authentication ...

[Sat Oct 01 10:02:33 2005] [notice] Digest: done

[Sat Oct 01 10:02:34 2005] [notice] Apache configured -- resuming normal operations

I don't know how to make it work faster, but in the meantime I'm happy just to wait for a couple of minutes while it sorts itself out.

----------

## Taily

Well for me the apache server would just "hang" at

```
[Sat Oct 08 00:12:27 2005] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Sat Oct 08 00:12:28 2005] [notice] Digest: generating secret for digest authentication ...
```

However when you did /etc/init.d/apache2 stop.. the server would actually not die, it finnishes loading itself and is alive :/

This was all due to an error in apache configuration. I suggest running apache2 -k stop after you've started it and see if it reports some error.

----------

## j-m

 *Quote:*   

> emerge sys-apps/clrngd

 

 :Idea: 

----------

## bytelab

I have the same problem but after a little testing I found it to be an entropy issue.

Thanks guys for a very informative thread  :Wink: 

----------

## TJNII

Wow.  I never knew a computer could run out of entropy.   :Razz: 

```

PrISUm2 / # ps -ec | grep apache

25393 TS   14 ?        00:00:00 apache2

PrISUm2 / # emerge -s I_Like_Pudding

Searching...   

[ Results for search key : I_Like_Pudding ]

[ Applications found : 0 ]

 

PrISUm2 / # ps -ec | grep apache

25393 TS   23 ?        00:00:00 apache2

25482 TS   21 ?        00:00:00 apache2

25484 TS   20 ?        00:00:00 apache2

25485 TS   19 ?        00:00:00 apache2

25486 TS   18 ?        00:00:00 apache2

25487 TS   17 ?        00:00:00 apache2

25488 TS   15 ?        00:00:00 apache2

PrISUm2 / # 

```

----------

## ohcnetwork

Hi, I know that this is not RHE or Apache forum, but after I spent many hours searching for a solution to my problem, I only found a few places that discuss the problem, and this seems to be one place that I can ask about the problem and its possible solution, so I'm posting here.  Hope it's ok ...

I am having a similar problem, and Apache2 installed on my server hangs.  Apache2 is installed on RHE and it happens periodically.  I tried to find causes, but the reason why I'm posting here is that I see the following error message in my error log file (and this is mentioned in this thread):

```

[Fri Dec 23 01:00:30 2005] [notice] Digest: generating secret for digest authentication ...

[Fri Dec 23 01:00:30 2005] [notice] Digest: done

```

I see the notice recorded number of times although this is not exactly when Apache2 hangs.  My questions are as follows:

Q1. Does the notice indicate that Apache2 can hang periodically?

Q2. If so, does commenting out modules/mod_auth_digest.so resolve the problem (temporarily)?

Q2.2. What does modules/mod_auth_digest.so really do and do I need it?

Q3. A couple of people mention about entropy in this thread, but what is it (my apology if this is such a trivial question)?

Q4. If entropy is really the problem on my system, how do I know if it's really the case?

Q5. If it is the case, how can I fix it?

----------

## ocbMaurice

Your Problem is not likely related to the entropy pool. The problem with the entropy pool is the automatic generation of the secret for mod_auth_digest. To create a new secret (cypher key) it needs some (real) random data which is taken from the entropy pool. If the entropy pool is empty, the generation will take a long time. But in your case the generation was done in a very short time.

----------

## ohcnetwork

 *ocbMaurice wrote:*   

> Your Problem is not likely related to the entropy pool. The problem with the entropy pool is the automatic generation of the secret for mod_auth_digest. To create a new secret (cypher key) it needs some (real) random data which is taken from the entropy pool. If the entropy pool is empty, the generation will take a long time. But in your case the generation was done in a very short time.

 

... then what is causing Apache (on my server) to hang?

----------

## mizery de aria

*bump*

having this problem too...

----------

## pirus3210

i had the same problem.. Apache2 wouldnt start.

Try 

#ps aux

if you can see apache there do this

#pkill -KILL apache

then try restarting

----------

## LL0rd

Hi,

I have exactly the same problem. 

```
[Fri Dec 23 01:00:30 2005] [notice] Digest: generating secret for digest authentication ...

[Fri Dec 23 01:00:30 2005] [notice] Digest: done 
```

That problem appears, when I try to restart apache with the restart command. You can do everything you want, you can't get apache up. But if I restart apache with stop and then start, apache runs without problems. To solve the problem with hanging apache, I restarted the whole OS, after that, I could start apache with the start command. 

Thats a realy strange behavior, it's like...... windows  :Wink: 

----------

## Bash[DevNull]

I've removed "LoadModule auth_digest_module modules/mod_auth_digest.so" line from config,

BUT it's not HELP me because on restart/start apache2 freezes (50-200sec) on reading from /dev/random!!!

Why? I have no other digest modules....

----------

## LL0rd

okay, I don't realy know, what the error realy is, but I had restarted my apache webserver. After the restart I had just one apache process. Then me and my girlfriend hat a little bit fun   :Very Happy:   :Cool:   :Very Happy:  After about half an hour I was back and apache was running

----------

## maverick6664

Thanks all.  Having the same problem I found this thread today, and finally found tapping the keyboard (not on a remote console, but on the "real" console w/o X Window) seemed to help.   :Smile:   Maybe moving the mouse or other factors will also help.   

The value of /proc/sys/kernel/random/entropy_avail on my http server is often low (around or below 100) and this value actually affects the freezing time period.  My kernel is generic 2.6.16.

EDIT: Running X Server doesn't seem to matter at all.   Keyboard and mouse always affect much.  Moving mouse is the most efficient in my case.

----------

## eltech

 *j-m wrote:*   

>  *Quote:*   emerge sys-apps/clrngd 
> 
> 

 This did work for me today as i ran into this problem .. and i just ran clrngd and the problem has been fixed, but will this run again on its own if and when centropy memory runs out ?

how can i prevent such happening>?

----------

## okuhl

Hi,

this worked for me, too:

```
# cat /proc/sys/kernel/random/entropy_avail

0

# emerge -a clrngd

# /etc/init.d/clrngd start

# cat /proc/sys/kernel/random/entropy_avail

256

# /etc/init.d/apache2 start

```

Regards,

    Oliver.

----------

## soth

yay! No more problems for me!

----------

## eltech

this may temporarily fix th problem .. atleast for me it was until

https://forums.gentoo.org/viewtopic-t-454662-highlight-.html

----------

## madCoder|GN

I had this problem also.  One time it took 38 seconds to start, another time it took 2 minutes.  Then another time I let it sit for about 10 minutes and it was still stuck trying to generate the digest secret.

Following another suggestion in this thread, I did 

```
emerge -s to
```

 and it generated enough entropy to let Apache finish loading, and all was well after that.

How would I know if I have a hardware RNG to take advantage of rng-tools?

Has anyone submitted a bug to Apache? Suggesting that it should put something else into the log, like "... This may take a long time", or if there's not enough entropy available, it would do another message after maybe 15-20 seconds saying "There is not enough entropy, waiting for entropy to become available.  Try performing some random tasks on the server.", and also making apache NOT open the bind port until after the digest is generated.

----------

