138

I don't know what the problem is. WAMP was very slow, so I reformatted my computer and installed WAMP. Still, accessing localhost is very, very slow, and sometimes it doesn't even load at all. I even removed it and replaced it with XAMPP, but I still got the same result. What might possibly be the problem? Here's my current hosts file:

127.0.0.1       localhost

127.0.0.1       localhost

It was perfectly working fine before, but I do not know what happened and why it has started acting strange lately, since even a reformat didn't fix it.

7
  • 4
    I have also the same issue. The issue was with Apache's main settings file httpd.conf. See this link for a solution that worked for me: serverfault.com/questions/66347/…
    – Jitendra
    Dec 8, 2011 at 14:39
  • I added LoadModule php5_module "C:/xampp/php/php5apache2_2.dll" on htpd.conf and restarted it but it didn't help at all.
    – FBwall
    Dec 8, 2011 at 14:46
  • Hmm, do you have a fresh install of xampp or do you have any frameworks running? Also you dont need this line 127.0.0.1 localhost in the hosts file twice so try taking one out
    – cowls
    Dec 8, 2011 at 16:18
  • the problem got fixed, i did nothing. It just suddenly responded fast again after a couple of days. Sigh.
    – FBwall
    Dec 11, 2011 at 10:29
  • @all, I have a question for those that proposed solutions that involve adding or replacing text with 127.0.0.1: what happens if you access 127.0.0.2, or 127.1.2.3 or some other loopback address? For example, if MySQL is bound to 127.0.0.2, will hard-coding 127.0.0.1 in the Apache conf files still work?
    – Synetech
    Nov 19, 2013 at 21:28

27 Answers 27

118

I had the same problem running on Windows 8 running on 64bit. Apache is really slow but when you press F5 many times it goes ok. In the end i after doing many things managed to solve it. Right now it works fast.

Try the following tasks to increase the performance:

Change apache's listening port

Change listening port from 80 to 8080 to avoid conflicts with programs like Skype. Open your httpd.conf file and find the line that starts with Listen (it's around line 62). Change it like the following: Listen 127.0.0.1:8080

enter image description here

Change your powerplan

Change your power plan from Balanced to High Performance. You can do this in Control Panel\All Control Panel Items\Power Options

enter image description here

Disable IPv6

The credits of this particular task go to Jef where he pointed this out in his blog post. From the Windows 8 desktop, press the Windows Key and the R key at the same time

enter image description here

Type regedit in the Run dialog box and click OK

enter image description here

Use Registry Editor to expand the registry tree and browse to:

\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP6\Parameters

enter image description here

Right click on Parameters, expand New, and select DWORD (32-bit) Value

enter image description here

Enter DisabledComponents into the Name field

enter image description here

Double click on the new DisabledComponents value, enter ffffffff into the Value data dialog box, and click the OK button

enter image description here

Confirm the new registry value contains the required data.

enter image description here

Change your etc/hosts

If you use virtual hosts don't add each virtual host on a new line. Instead list them like the following. 127.0.0.1 site-a site-b site-c

I also added 127.0.0.1 127.0.0.1 since I heard this somehow improves the lookup as well. (Can't confirm this but it can't hurt putting it there)

enter image description here

Your hosts file is located at C:\Windows\System32\Drivers\etc

Check how many apache processes are running

In my case I had two apache processes running. Be sure you only have one running. You can check this by pressing CTRL+ALT+DEL and press Task Manager

enter image description here

Turn off the Base Filtering Engine (BFE)

What I find to be working a bit as well was turning off the Base Filtering Engine. Since stopping or disabling the BFE service will significantly reduce the security of the system you should only do this when needed.

Go to Control Panel => Administrative Tools => Services => Base Filtering Engine

enter image description here

Stop the Base Filtering Engine by clicking on Stop

enter image description here

Increase Apache's process priority

To to your task manager and change Apache's process priority from Normal to High by right clicking -> Set priority -> High enter image description here

Keep Apache's process busy

This is a bit of an ugly method but it does certainly work. It keeps Apache busy and will process your own requests faster. Insert your local web-address in the iframe location and save it in a html file, run it and just leave it there until you're done.

<html>
    <head>

<script>
setTimeout(function(){
   window.location.reload(1);
}, 2000);

</script>

</head>
<body>
<iframe name="iframe" id="iframe" src="http://mywebsite:8080"></iframe> 


</body>
</html>

Downgrade to Windows 7 Pro

As a Windows 8 Pro user you are entitled to have downgrade rights to Windows 7. Read here more about this. For me that was the only solution that really did the job properly.

17
  • 7
    this is a good collection of answers, the only thing i did and work for me was disabling IPv6, thats all, so thanks ;) Jul 29, 2013 at 19:39
  • 24
    I also added 127.0.0.1 127.0.0.1 That’s not even valid syntax for a HOSTS file; you cannot remap an IP address. Check how many apache processes are running. In my case I had two apache processes running. Be sure you only have one running. What‽ You’re supposed to have two instances of httpd.exe; that’s expected and normal. The second one is the worker which does the main work, and the first is just the monitor which can restart the worker if it crashes. You only get one in debug mode which is not meant for regular use.
    – Synetech
    Nov 20, 2013 at 22:10
  • All these things may be not valid, regular, etc but at least it makes apache go faster. That you have to wait ten seconds to load a page is also not expected but is regular in Windows systems. In the end it may be better to switch to Mac or Ubuntu if you don't mind the bugs within the system.
    – bicycle
    Nov 20, 2013 at 23:08
  • Very nice, thorough comment, but with little downside for me... instead of putting Apache on port 8080, we'd better disallow Skype to use ports 80 and 443. It is done in Skype's connection settings. Pointing to 8080 is not a good practice from a developer's point of view, basically because it may conflict with Apache Tomcat that runs on default on 8080, and is also included in the XAMPP package. Jan 27, 2014 at 18:36
  • 1
    @MartinAsenov: if it's only Skype, that's fine, Skype can be easily redirected to another port. But I have port 80 issues with few other programs like Dropbox, which is not so easy to move to another port.
    – Pavel V.
    Dec 18, 2014 at 7:09
95

This is caused by IPV6. Here is how you make MYSQL not use it. (so, without disabling IPV6)

edit mysql file 'my.ini'

under [wampmysqld] or [mysqld] add the following:

bind-address = ::

Save file and restart mysql service

enjoy!

10
  • 3
    Perfect! I gave your answer a 5% chance that it would help, but it really did! thanks.
    – AndiPower
    Jun 4, 2015 at 15:54
  • 5
    Thanks man Speed improved a lot... As I am using XAMPP I have added it under [mysqld]
    – Sabeer
    Jul 21, 2015 at 15:32
  • 3
    This trick has helped me a lot.. it makes my MySQL server almost 100x faster.. it will works on WAMP or XAMPP.. For XAMPP, just remove the # sign before "bind-address = ::" line.. Aug 4, 2015 at 19:39
  • 1
    Updated my.ini for xampp with this and my localhost became lightning fast!!! Cheers to you!!!! Mar 12, 2018 at 4:49
  • 1
    This is the reason of my slow with XAMPP. x10 faster after follow this instruction.
    – sonnb
    Apr 27, 2020 at 16:17
55

have a look here :

http://forum.wampserver.com/read.php?2,91602,page=3

Basically use 127.0.0.1 instead of localhost when connecting to mysql through php on windows 8

if your finding phpmyadmin slow

in the config.inc.php you can change localhost to 127.0.0.1 also

7
  • 2
    That speed up the request time by about 80%. Why is PHP so slow to connect to MySQL with localhost under Windows 8?
    – wowpatrick
    Feb 12, 2013 at 13:29
  • 1
    This didn't fix it for me :( I know it fixed once in the past, but for some reason it isn't working now, sadpanda.
    – Benno
    Oct 15, 2013 at 0:00
  • It reduced the response time to 20% on windows 8.1. Thanks for the answer. Same question as wowpartick's
    – Ejaz
    Feb 12, 2015 at 17:50
  • Great - it reduced the request time from 1,03 sec. to ~15ms. Thanks! (Using win8.1 64bit) Jun 24, 2015 at 11:44
  • i had same problem, windows 8, phpmyadmin on localhost was opening one small table (29k rows) forever.. once i changed address in URL bar to 127.0.0.1 it loaded instantly.. very strange
    – luky
    Oct 18, 2016 at 20:57
48

The solution that worked for me was to disable the cgi_module. Use one of these methods:

(Method 1) Right click on WAMP > Apache > Apache Modules > uncheck "cgi_module"

(Method 2) Edit httpd.conf and disable the loading of the CGI module by commenting this line:

LoadModule cgi_module modules/mod_cgi.so

Commenting would be just adding a # in front, like this:

#LoadModule cgi_module modules/mod_cgi.so

Restart the Apache service and you should be good to go.

5
  • +1 It works like a charm! This one on its own did the trick! I'm on Windows 7 Pro + Apache 2.4 + PHP 5.5.30. Nov 21, 2015 at 13:25
  • This work for me. Using El Capitan (MAMP) + Apache 2.2.29 + PHP 5.6.10. Especially the lag when running Parallels IE Test Environment.
    – fidev
    Jan 24, 2016 at 20:29
  • Yes - I've tried lots of things - this works for me using XAMPP on W7Pro. It also seems to have fixed some annoying phpMyAdmin stalled refreshes where PMA sits there with a clock icon. Oct 28, 2016 at 17:22
  • This is the only thing that worked for me. All the other known fixes I tried and didn't work but this did
    – AdRock
    May 2, 2017 at 11:06
  • even 2021 this solution is working! Win10, Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.3.11 Datenbank-Client Version: libmysql - mysqlnd 5.0.12-dev
    – summsel
    Feb 26, 2021 at 1:10
47

In my case, load time is 5 times faster when this is disabled in php.ini :

;zend_extension = "\xampp\php\ext\php_xdebug-2.1.0-5.3-vc6.dll"
8
  • 1
    I've been looking for the cause of this for more than a year now. For me, this was the main and sole culprit. Here's a post that describes what you can do besides having to disable Xdebug: stackoverflow.com/questions/24893010/… Thanks! Nov 16, 2014 at 14:20
  • 1
    Thanks, thanks, thanks, thanks!!! I have been trying everything that is writte up here and elsewhere. And XDEBUG was that thing that made phpMyAdmin slow as hell. And now it flyes again!
    – hbit
    Apr 5, 2015 at 12:05
  • 1
    Exact same problem, even with a newer copy of the extension. Just quicker for me to comment it out when not needed, but probably related to one of the other .ini settings with the extension. Apr 24, 2015 at 17:35
  • 1
    You hero! In the end I left xdebug enabled, but turned off the profiler and my script sped up from around 5 minutes to 5 seconds. Thank you! Nov 27, 2015 at 15:18
  • 1
    for me, this was the only thing to speed it up. surprisingly, internet explorer 11 was really fast with xdebug enabled. chrome and ff were slow as hell...
    – Guntram
    Mar 30, 2016 at 8:50
22

For me using xDebug, this line in php.ini was the performance killer:

xdebug.remote_autostart=true

When I removed it the page was fast again.

1
  • Disabling the xdebug extension (zend_extension line) worked for me. Now I need a new debugger -.-" Thanks for pointing me to the right direction
    – kosmos
    May 9, 2018 at 10:07
17

if you are using mysql use 127.0.0.1 instead of localhost in mysql_connect function it helped me

0
15

I'm not yet able to comment under @Honesta answer, so I'll write here the way I manage to solve it.

My environment (I don't know if this is relevant for the answer)

  • XAMPP (version 5.6.3)
  • Windows 8.1 Pro (64 bit)

How to

I just opened my.ini file and uncommented the line where it says

bind-address="127.0.0.1"

This file is located, for XAMPP users, in C:\xampp\mysql\bin\my.ini.

Credits

This article helped me to solve the problem, although I didn't needed everything in it because some setup in XAMPP were not requested.

9

I've just fixed such an issue on my laptop running windows 10. Suddenly wamp became super slow - a request to load a page was taking 2 minutes.

After trying numerous things, what it turned out to fix the problem was disabling windows defender. All worked like a charm after that.

p.s. I'd suggest you add your apache root dir to the exceptions list and not actually disable defender completely.

2
  • THIS!!!! You are a life saver, spent hours and hours trying to get to the bottom of this!!
    – Gisto
    Feb 27, 2020 at 16:12
  • This worked like charm for me, I've been struggling with this problem for weeks Apr 30, 2020 at 21:53
6

As most of the answers have pointed out, using the IP address 127.0.0.1 over "localhost" will sometimes help the slowness issue - but this isn't really a solution because it does not fix the underlining problem.

What makes this problem hard (and hit-and-miss), is it can be caused by about a dozen different things between the OS, the WAMP configuration, and your Browser.

  1. Remove ::1 localhost from your Windows hosts file, and make sure 127.0.0.1 localhost is present. You want your request to go directly to the listening IPv4 socket.

  2. Disable IPv6 on your system. You are most likely not using it, and it has been known to cause all kinds of issues.

  3. Exclude your Apache and MySQL binary paths, and the Database folder, from your firewall and anti-virus software. They will interfere and slow things down.

  4. Reset your TCP/IP sub-system and reboot: netsh int ip reset c:\resetlog.txt

  5. Make sure your system is not using stale DNS servers: ipconfig /all

  6. Flush Windows DNS cache: ipconfig /flushdns

  7. Clear your Browser's Cache.

A little more in-depth is this guide: WAMP is Running Very Slow

1
  • first thing i do this and its working wonderfully, other tricks answered above definitely might work, just because this at the bottom of answers, i tried this first and solve my problem, cool ! Sep 26, 2018 at 6:09
6

After try each instuction on this post, for me works when i add in:

Avira >>
Real-Time Protection >>
Configuration >>
Exception >>

Add Proccess:

  1. xampp\apache\bin\httpd.exe
  2. xampp\mysql\bin\mysqld.exe
  3. xampp\xampp-control.exe

enter image description here

2
  • I'm using Windows Defender and this solution worked for me, I just added the three files to the "Excluded processes" list in Defender
    – Kevin
    Apr 3, 2017 at 22:10
  • This solution worked for me, I tried all the others but noticed in my task manager once I launch the local host, very many processes related to bit defender service host will start running. Added the exceptions to bit defender and now works like charm. Sep 15, 2021 at 16:03
4

For my it was the xdebug. I disabled and it worked as it should be !

[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.3.2-5.6-vc11.dll
1
  • It was exactly what happened to me. Thank you for remember me! Mar 25, 2019 at 17:45
3

I am using wamp64 on my windows 10 machine. I was having the same issue and turning off Xdebug of from my php.ini file resolves the issue for me.

; [xdebug]
; zend_extension ="C:/wamp64/bin/php/php5.6.25/zend_ext/php_xdebug-2.4.1-5.6-vc11-x86_64.dll"
; xdebug.remote_enable = off
; xdebug.profiler_enable = off
; xdebug.profiler_enable_trigger = off
; xdebug.profiler_output_name = cachegrind.out.%t.%p
; xdebug.profiler_output_dir ="C:/wamp64/tmp"
; xdebug.show_local_vars=0
2

I had the same problem. Response times were extremly slow and refreshes worked quickly, most of the time. All suggestions made by bicycle didn't help. What seems to help best so far (no slow response times for the last 30mins) was to reset winsock as explained here: http://www.devside.net/wamp-server/wamp-is-running-very-slow

netsh winsock reset
netsh int ip reset C:\resetlog.txt

You need to restart after this.

1
2

Using Windows 10 (june of 2018), I managed to improve the loading that went from 2 seconds to less than 400 milliseconds doing a set of things I saw in this post and the internet

Disabled xdebug in php.ini

; [xdebug]
; zend_extension ="C:/wamp64/bin/php/php5.6.25/zend_ext/php_xdebug-2.4.1-5.6-vc11-x86_64.dll"
; xdebug.remote_enable = off
; xdebug.profiler_enable = off
; xdebug.profiler_enable_trigger = off
; xdebug.profiler_output_name = cachegrind.out.%t.%p
; xdebug.profiler_output_dir ="C:/wamp64/tmp"
; xdebug.show_local_vars=0

Used 127.0.0.1 in installation, in my case of Wordpress

Using @honesta method

edit mysql file 'my.ini'

under the [wampmysqld] add the following:

bind-address = ::

And disabling cgi module like @Iulian Dita said

The solution that worked for me was to disable the cgi_module. Use one of these methods:

(Method 1) Right click on WAMP > Apache > Apache Modules > uncheck "cgi_module"

(Method 2) Edit httpd.conf and disable the loading of the CGI module by commenting this line:

LoadModule cgi_module modules/mod_cgi.so
Commenting would be just adding a # in front, like this:

#LoadModule cgi_module modules/mod_cgi.so
Restart the Apache service and you should be good to go.
1

Had the same issue in Chrome and it did not go away after applying all the known remedies. For me the resolution was to uncheck "Enable phishing and malware protection" in Chrome settings (Settings -> Show advanced settings -> Privacy). After that localhost is lightningfast.

1

I had this problem too.

I added the entries suggested above but it failed to work.

It was due to the fact Spybot Search and Destroy had added 15,000 lines of immunized site (ie prevents you from visiting them) to my hosts file.

My hosts file was 433k - I removed those lines and my page load speed improved immensely.

1

Changing(Updating) my PHP version from 5.5.25 to 7.0.10 solved this problem in my case.

1

Power plan was the problem.Changed Balanced to High performance.

0

I have the same issue but I resolve issue from database.I had rename table name and create new table with out index through which all indexes effected and I had huge amount of data in table.I again rename original table, it has fixed for me.

0

If you are using PHP Xdebug for debugging purpose, remove that file. It worked for me. The response time reduced from 950ms to 125ms.

0

I don't know why, but closing my internet connection solved this problem for me.

0

I have had suspicions Chrome is starting to get stupid and bulky for a while, and my problems started after updating it. Since Ampps worked better when connected to Internet I put 1 + 1 together. Under Chrome Advanced settings try to dig into the Preload webpages for better performance feature. And kill it.

Ironic, but not unexpected, as it seems to get confused about preloading Localhost. In my case it was the instant fix after hours of wasted config fiddling and weeks of suffering.

Thank you Google devs.

0

After trying some answers and comments here, I finally found a solution! In this article The correct way to configure PHP I find a new way to configure PHP as a module in Apache.

For the author of this article, the official way to configure PHP is not the most optimal. The common and inappropriate way to configure PHP is this one:

# For PHP 5:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"

I've always done it this way, but in the article, it's suggested to configure the PHP module this way:

#For PHP5
LoadFile "C:/www/php5/php5ts.dll"
LoadModule php5_module "C:/www/php5/php5apache2.dll"

<IfModule php5_module>
    #PHPIniDir "C:/Windows"
    #PHPIniDir "C:/Winnt"

    <Location />
        AddType text/html .php .phps
        AddHandler application/x-httpd-php .php
        AddHandler application/x-httpd-php-source .phps
    </Location>

</IfModule>

I even have IPV6 enabled, and my loading time drop down from 45 secs or 1 minute or more, to just 2 or 4 seconds! Thanks to other answers mentioned here, I also left enabled in my general configuration the following

HOST FILE:

127.0.0.1       localhost
127.0.0.1       127.0.0.1
#   ::1         localhost

HTTPD.CONF

EnableMMAP on
EnableSendfile on
AcceptFilter http none 
AcceptFilter https none
HostnameLookups Off

Other than that, I rolled back all other solutions I tried, so I'm sure this is the only ones that I used.

0

I have enebled xdebug. And I found that when my IDE PhpStorm was shutdown it was very slow. After I started my IDE, than it was fast. I dont know why but hope that it will help other people.

-2

Just try "Incognito" mode in Chrome.

Finally, this helped me to solve my issue.

Please keep your mind, this is not a permanent solution.

-6

I run on wamp and I had this problem once. There can be many factors to this though there is 5 main ones that come to my mind.

1st. A program can cause this(Even antivirus software just depends what you have.)

2nd. Is your computer full or using alot of space this happen to a partner site of mine.

3rd. Check your regerstry files there could be errors or other things. (This end up being my problem.)

4th. After you uninstalled it did you manually delete the files that were left on your computer.(Yes even after you uninstall with wamp it has a tendency to leave a folder or 2 with some important data on it. When you install this will not be remodified and will stay the same.)

5th. Download the latest wamp or the lastest stable version of it.

Hope one of these things help.

Not the answer you're looking for? Browse other questions tagged or ask your own question.