Apache 2.4 on Windows responds slowly, hangs when serving some dynamic pages

30

20

(I know the answer to this question. Posting this just to share the answer with the community)

My local (Windows 7) instance of Apache 2.4 experiences delays or hang-ups when serving some URLs, depending on which browser I use to access these URLs.

With Firefox/Chrome, Apache is slow to respond on certain URLs. The sluggishness occurs about 20% of the time on any given URL. When it does occur, there's a 5-second delay during which Firefox displays a "Waiting for..." status.

With Internet Explorer 9, Apache simply hangs and stops serving any requests (with any browser) until it is restarted.

  • This seems to occur only with dynamic (PHP) requests, but not all of them. In fact, it only occurs on one specific site. Other PHP-based sites on the same machine work fine.
  • It may or may not be significant that the problematic site consists of a large number of subdomains (VirtualHosts).
  • Disabling the Windows Firewall and Comodo Firewall doesn't help.
  • The problem seems more frequent with "busier" pages (additional requests for IFRAMES etc.)

I've tried many changes to httpd.conf (such as disabling KeepAlive, EnableMMAP, HostnameLookups) but nothing seems to work.

Tomasz P. Szynalski

Posted 2012-12-07T02:28:41.630

Reputation: 301

1For finding this posting here through Google: The below solution also works for this error: "(OS 64)The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed.". In German: "(OS 64)Der angegebene Netzwerkname ist nicht mehr verfügbar. : AH00341: winnt_accept: Asynchronous AcceptEx failed.". – Uwe Keim – 2016-01-25T05:57:58.657

1Once you have some up-votes, you'll have the reputation to move the answer into a real answer, which you should do then. (If nothing else, the upvotes will get you more reputation then.) – pjmorse – 2012-12-07T02:50:40.503

Answers

35

Answered by Thomasz


The solution is to add the following to your httpd.conf:

AcceptFilter http none
AcceptFilter https none

On Windows, this has the effect of disabling the AcceptEx() API (part of WinSock), which offers some performance improvements, but probably conflicts with Comodo Firewall.

Putting Comodo Firewall in "Disabled" mode doesn't help because requests probably still go through Comodo's networking code. I think Comodo would have to be uninstalled completely to eliminate the problem (though I haven't tried it).

If you have a similar problem with Apache 2.2, you should use the Win32DisableAcceptEx directive instead.

References

Quoting from http://httpd.apache.org/docs/2.4/mod/core.html:

The default values on Windows are:

AcceptFilter http data

AcceptFilter https data

Window's mpm_winnt interprets the AcceptFilter to toggle the AcceptEx() API, and does not support http protocol buffering. There are two values which utilize the Windows AcceptEx() API and will recycle network sockets between connections. data waits until data has been transmitted as documented above, and the initial data buffer and network endpoint addresses are all retrieved from the single AcceptEx() invocation. connect will use the AcceptEx() API, also retrieve the network endpoint addresses, but like none the connect option does not wait for the initial data transmission.

On Windows, none uses accept() rather than AcceptEx() and will not recycle sockets between connections. This is useful for network adapters with broken driver support, as well as some virtual network providers such as vpn drivers, or spam, virus or spyware filters.

See also: http://forums.comodo.com/help-for-comodo-antivirus/conflict-with-apache-t260.0.html;msg31636#msg31636

Eric Fossum

Posted 2012-12-07T02:28:41.630

Reputation: 541

1I've been having issues with IE10 causing Apache2.4 (no comodo involved) to hang until the service is restarted - and changing the .conf to include these fixed it. Thanks for posting this. – matt lohkamp – 2013-08-15T00:26:48.783

1

This worked for me as well. I also gathered some more references on my blog as the info about this topic is very scattered at the moment.

– Stijn de Witt – 2014-01-09T23:55:54.450

3Worked for me, Win 7 x64. I wonder why none is not the default setting in Apache? Most other 'innovative' features are disabled by default in Apache :P – rustyx – 2014-05-18T12:36:05.657

-1

I'm running Apache 2.4.16 on a Windows 7 Pro box, and my website just stopped working about 2 weeks ago. Adding this fixed the problem.

ServerRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.4"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen XX.XX.XX.XX:80
Listen 80
AcceptFilter http none
AcceptFilter https none

pluckyduck

Posted 2012-12-07T02:28:41.630

Reputation: 9

Down voted because your answer is exactly the same as the one above by @Eric Fossum. – hargobind – 2017-04-08T07:04:49.110