66

Having real trouble using my localhost to test sites. It runs extremely slowly! Sometimes it takes up to a minute to load a page. I'm using Firefox and the sites I'm testing run fine on other developers in my office's local machines / on the production server.

I've gone through the normal things :-

  1. Disabled IPv6
  2. Not running in debug mode
  3. Put the site in the highest app pool (High Isolated) on IIS 6.
  4. Taking of firewalls etc.

The problem only seems to occur when hitting pages which contain some form of .net code in the code-behind.

Appreciate that this a little bit of a vague topic / stab in the dark but would appreciate any sort of advice - it's horrible waiting a minute each refresh to try out a change!

Cheers, Sean.

int3
  • 12,861
  • 8
  • 51
  • 80
royse41
  • 2,310
  • 4
  • 22
  • 29
  • What kind of pages are you trying to view? Is it for example a VS2008 project? – Younes Mar 05 '10 at 11:26
  • Something's up with your DNS resolver. Not being a Windows expert I can't say precisely what, but on a Linux box this is what happens if localhost is missing from /etc/resolv.conf. Windows has an analagous file somewhere in the System directory. – Andrew McGregor Mar 05 '10 at 11:58
  • 7
    LOL - 1 minute, huh? I started my **localhost**, checked all of my emails, provided feedback on all of the items I recently purchased on eBay, browsed around on eBay a while, got tired of waiting for **localhost** to start, googled `"slow localhost"`, came here, read this post, submitted my reply, and my **localhost** is still trying to start. –  Mar 25 '14 at 20:23
  • 1
    Was just about to write the same @jp2code localhost is taking FOREVER. – Love2Code Apr 01 '21 at 15:44

19 Answers19

50

I had the same problem with PHP. I solved it by changing "localhost" to "127.0.0.1" in database connection parameters like someone suggested here: https://serverfault.com/a/444338/62739 . I think it may work for you too, give it a try.

Community
  • 1
  • 1
grongor
  • 1,305
  • 1
  • 13
  • 26
  • 1
    Using Flask to build a python web service and during unit testing was seeing ~1 second between queries consistently. I was using `http://localhost:5000`. When I switched to `http://127.0.0.1:5000` the problems went away completely. I tried removing `::1 localhost` from my hosts file but it didn't change anything. – cod3monk3y Jan 26 '14 at 06:32
  • Finally for me trying `Mr. James` **solution** from [here](http://stackoverflow.com/a/4969403) worked, hope helps someone. – Shaiju T Jul 26 '15 at 10:51
  • it worke when i reinstall wordpress but it doesnt work when i edite wp.config,php – Abubakr Elghazawy Apr 09 '19 at 07:22
  • @grongor, same for me, just changed the $dbname from 'localhost' to '127.0.0.1', and the slowness went away. Any idea why is that? – limestreetlab Dec 07 '20 at 16:20
17

Just Sharing my solution... i changed the url in my browser from localhost:port to 127.0.0.1:port which resulted in very fast loading

SoliQuiD
  • 2,093
  • 1
  • 25
  • 29
  • @finnTheHuman all i can think about is that something is taking time while translating the keyword to the appropriate address.. im notsure tho – SoliQuiD Jun 03 '15 at 12:45
  • of course these are desperate solutions, not real solutions – SoliQuiD Jul 16 '20 at 08:49
9

I had same issues, edited my hosts file 127.0.0.1 localhost, but noticed no difference.

I then disabled Compression in the IIS panel and applied, and problem appears to now be resolved.

IIS Manager > Compression > Uncheck 'Enable dynamic content compression' and uncheck 'Enable static content compression'. Then 'Apply'.

Pang
  • 9,564
  • 146
  • 81
  • 122
Geoff
  • 369
  • 5
  • 11
  • This appears to have fixed it for me, but I don't understand why it would when FF loaded fast with these options turned on. Anyway, really, what do I care. My dev sites now load super fast, even after a compile. – Ads Dec 02 '16 at 13:47
7

I was having the same issue, IIS initial loading would take up to 10 minutes instead of the usual 30 seconds.

I opened up Task Manager to see what processes were running. Turns out Windows Defender would spike at 30% CPU usage when hitting the IIS endpoint for the first time. I tried excluding my /bin/ folders but that did not work, so I just disabled real-time protection on Windows Defender and voilà the site was loading in just 30 seconds.

Bilal
  • 81
  • 1
  • 3
  • Thanks. Your answer gave me a good start. I wrote a blog post listing all the required steps to get the refresh time of <5 secs instead of ~10 mins http://www.mandeepjanjua.com/post/running-sites-on-localhost-are-painfully-slow – Mandeep Janjua Jun 23 '19 at 17:28
5

Try to enable the Bypass proxy server for local addresses. This works for all browsers installed (Firefox, Chrome, etc).

  1. Open Internet Explorer by clicking the Start button Picture of the Start button. In the search box, type Internet Explorer, and then, in the list of results, click Internet Explorer.

  2. Click the Tools button, and then click Internet Options.

  3. Click the Connections tab, and then click LAN settings.

  4. Select the Use a proxy server for your LAN check box.

  5. Select the Bypass proxy server for local addresses

Dherik
  • 17,757
  • 11
  • 115
  • 164
  • 1
    yup; this why `localhost` was slow for me - IT guys cleared all that out so it would auto-configure to a domain proxy. Bypassing fixes the slowdown. – Meirion Hughes Aug 23 '17 at 09:30
  • 1
    Boom! I thought I'd already made this change - nope. debugging lickety-split now. – JonV Apr 07 '21 at 16:15
5

Disable the antivirus on the folders where is the code of the web application. In my case I have observed a big improvement with Avast antivirus.

dlopezgonzalez
  • 4,217
  • 5
  • 31
  • 42
5

This suggestion fixed it for me. Clear out the WebSiteCache in C:\Users\username\AppData\Local\Microsoft\WebSiteCache

http://blog.geocortex.com/2007/12/07/slow-visual-studio-performance-solved/

James
  • 1,440
  • 14
  • 12
3

For people using a mac. When you're using different host names say test.local and test2.local. Try changing test.local to test.dev. I found out that Mac OS X lion controls the .local tld. So when you change it to something else it's faster.

And of course use above suggestions like turning off the ipv6 reference in your hosts file:
#::1 localhost

and setting this in the hosts file: 127.0.0.1 localhost

so it points to ipv4.

2

If you are just viewing the page output (not debugging code) then go to the Web.Config file and set debug to false. This changes load time from >15 secs to <1 sec

    <system.web>
        <compilation debug="false" strict="false" explicit="true" targetFramework="4.0" />
        ...
    </system.web>
SunOfABee
  • 31
  • 4
2

If your using .Net then turning off debug in your Web.Config is going to improve performance no end.

<compilation defaultLanguage="c#" debug="false" batch="false" targetFramework="4.0">
davidjones
  • 67
  • 5
  • 3
    Although debugging something you need on a local installation. Debug mode on should not be the reason pages load incredibly slow. – Nickvda Dec 03 '14 at 12:00
  • This makes absolutely no sense given that the same site can load ultra quick in IE and FF in debug mode.. Only Chrome has the issue for me. – Ads Dec 26 '15 at 12:17
2

I just changed my hosts file from this:

127.0.0.1       abc.com.au
127.0.0.1       def.com.au
127.0.0.1       hij.com.au

to

127.0.0.1       abc.com.au def.com.au hij.com.au

Note: The concatenated website line cant exceed a couple of hundred characters.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
1

I know the op was using an older version of IIS and this may not apply to him, but I'm posting this as it might help others. I had the same problem and none of the above IPv6 or hosts file changes worked for me. My asp.net MVC4 project was really slow after hitting F5 to refresh js changes on localhost. It was happening across all browsers - Chrome, FF, and IE. Eventually I realised I was running IIS Express 8.0 locally, and it turns out 8.0 is extremely slow when serving up js files and seems to be a bug. If I ran iisexpress on the command line and hit F5 I could see each js file took 4 or 5 seconds to load.

I ended up uninstalling IIS 8.0 and installing IIS express 7.5 and straight away the problem was fixed. Here are the steps I followed:

IIS Express 8.0 seems to be installed with VS 2012 so if you had a new install or possibly a service pack update this might upgrade the previous IIS Express version.

Ciarán Bruen
  • 5,221
  • 13
  • 59
  • 69
1

I'm using Wamp Server, Windows 7 and a powerful machine.

My Apache is configured to run from a different port other than port 80. I also access my local site not via 'localhost', but a hostname mapped to my IP via dyn.com. I believe the fact that I'm running off of a different port than 80 seems to make Kaspersky's Web Anti-Virus feature very sensitive (since a lot of sketchy sites run off of different ports) and slows things down

Disabling it seems to have solved the issue.

1

I fixed this problem by editing config.inc.php file which is in phpmyadmin folder: specifically changed $cfg['Servers'][$i]['host'] = 'localhost' to $cfg['Servers'][$i]['host'] = '127.0.0.1'

Mike Shema
  • 261
  • 3
  • 5
0

After building your project the website needs some time to walk through the new dll :). It's normal that loading a webpage after rebuilding takes some time. This shouldn't happen when only changing something in for example javascript.

Younes
  • 4,825
  • 4
  • 39
  • 66
  • @Younes, that being said, it shouldn't take up-to a minute on a localhost to compile for first-run. @seanxe; do you have any .dll's in the /bin directory? Any web references or references from outside the .NET framework? Finally, any looping code or anything nasty somewhere? Can you post the code-behind in question? – dooburt Mar 05 '10 at 11:33
  • It can be anything as simple as Response.Write(DateTime.Now.ToLongDateString()); No dll's in the project, just standard talking to a database to retrieve data. I'm not building from VS2008 because that takes forever too, i just set my home directory to the project on IIS and browse to http://localhost/. @Andrew McGregor - have checked my hosts file and localhost (127.0.0.1) is in there fine. – royse41 Mar 05 '10 at 13:19
  • Sorry but then i won't be able to help you any further. I just know that using vs2008 and the dll's after rebuilding it will take long to load your website. – Younes Mar 05 '10 at 13:44
0

Run the Process Monitor to see what resources(Network, File, Registry, Threads) are being consumed and see any unnecessary resource(remote https, costly file reads) are being consumed

I had similar problem. When I run the process monitor I found that my fusion log is enabled so there are many into the disk which delayed the loading of dll after disabling fusion log IIS Express it is faster.

enter image description here

Thiru
  • 407
  • 5
  • 7
0

The cause of this for me was that the project was located on a network drive. I moved the project to the C: drive and everything ran without any delay.

If the project is located on a network drive, try moving it to your local C: drive and try it again.

The performance increase is much more than you would expect from just network speed. I guess VS is continually accessing the files when debugging an ASP.NET MVC application. I was using VS 2017, ASP.NET MVC debugging on IIS Express and this worked for me.

I hope this helps.

Alan
  • 66
  • 4
0

In my case, originally the following error was occurring:

Cannot read configuration file due to insufficient permissions

I fixed the error by using the proposed solution and restarted the application through IIS Manager. The original error was gone but the application was taking forever to load. I gave the permissions to IIS_IUSRS again but this time to the whole deployment folder. After this, the application was able to load though an error was showing up:

This configuration section cannot be used at this path

After resolving the above-mentioned error using the solution, the application was finally loading without giving any error.

tehmas
  • 164
  • 1
  • 8
0

See, Here may be some problems with your project:

  1. Poor coding. This is the most common problem everyone can face where you have coded something very poorly so it's using your resources too quickly.
  2. More than 3 seconds on localhost is extremely ridiculous since most of the sites online on internet load within 2 sec (better 1).
  3. Your machine has limited resources. Like low RAM or CPU. Most of the times this shouldn't matter but yeah, it matters.
  4. Your code is making external network request which is slowing things down. In that case you may use asynchronous programming.

Hope this helps..

Amax
  • 47
  • 8