[Fixed]-Django is very slow on my machine


Firefox has a problem browsing to localhost on some Windows machines. You can solve it by switching off ipv6, which isn’t really recommended. Using directly is another way round the problem.


None of these posts helped me. In my specific case, Justin Carmony gave me the answer.


I was mapping [hostname].local to in my /etc/hosts file for easy development purposes and dns requests were taking 5 seconds at to resolve. Sometimes they would resolve quickly, other times they wouldn’t.


Apple is using .local to do some bonjour magic on newer Snow Leopard builds (I think i started noticing it after updating to 10.6.8) and Mac OS X Lion. If you change your dev hostname to start with local instead of end with local you should be all set. Additionally, you can pretty much use any TLD besides local and it will work without conflict.


test.local could become:

  • local.test.com
  • test.dev
  • test.[anything but local]

and your hosts file entry would read:


Note: This solution has the added benefit of being a subdomain of [hostname].com which makes it easier to specify an app domain name for Facebook APIs, etc.

Might also want to run dscacheutil -flushcache in the terminal for good measure after you update /etc/hosts


I have had the same problem in the past. It can be solved by removing the following line from your hosts file.

::1         localhost

Once that’s gone you should be able to use localhost again, quickly.



Since you report your friend’s machine has no delays, and I assume yours and his are comparable computers, it could be a DNS related issue. Try to add both the client’s and the server’s IP address to the server’s hosts file.

If you run Django on *nix, it’s the /etc/hosts file. If run it on MS Windows, it’s the %WINDIR%\SYSTEM32\DRIVERS\ETC\HOSTS file. (They are text files and can be edited by your favourite text editor.)



I think it’s the development server, it’s not optimized for speed nor security. I noticed that specially serving static files (i.e. media) is slow.



And if all else fails, you can always cProfile your application and see where exactly is the bottleneck.


Had the same problem too, I’ve noticed it with Firefox on Vista and Windows 7 machines. Accessing the development server solved the problem.


Upgrade to Django 1.3 or newer.

If you still have this problem in 2012 (using Chrome), make sure you’re upgrading. In 1.3, a bug was fixed related to slowness when the dev server was single threaded.

Upgrading solved my issues. I was running Django 1.2 since that’s the default on Debian Squeeze.


I had the same problem but it was caused by mysqld.

The app worked pretty fast on production with wsgi and a mysql server in the same host but slow in the development environtment with the django runserver option and a remote mysql server.

I noticed using “show processlist” that connections in database where stuck in the state “login” with user “unauthenticated user” and this make me notice that the problem where in the authentication process.

Looking for the real problem, I finally noticed that mysqld was trying to get the dns name of my ip and disabling the name dns resolution, I fixed the problem.

To do that, you can add this line into my.cnf file:



I solved this issue like this:

go to setting.py and set

DEBUG = False


Disable AV Scanning & see if that makes a difference. It could also be caused by Vista. Upgrade to the latest service pack and try again.


To completely bypass localhost without altering the hosts file or any settings in Firefox you can install the addon Redirector and make a rule to redirect from localhost to Use these settings

Include pattern : http://localhost*
Redirect to     :$1

Leave the other fields empty.


i got the same problem.

the solution was :

  • I was trying to start localy a version that was usualy deployed on a webserver in production.
  • The static files in production were served by an apache config and not with django static serve

so I just uncommented back my static serve urls :/


Slow Loading of Static Files

If you notice that static and media files (images, style sheets, etc.) are particularly slow to load, the problem might be Django’s development server (python manage.py runserver). As noted by hassen, that server is not optimized for speed.

You can try using django-extensions runserver_plus command with the --threaded option as a replacement for Django’s runserver command. Under the hood, it uses Werkzeug as the threaded WSGI server. You may notice a huge improvement in loading times for static files.

Also see: Making Django development server faster at serving static media



For me it was Django Debug Toolbar – its amazingly helpful when its needed but when it isn’t it can slow development down which can be extremely frustrating and hard to identify. I find its better to disable it during development unless you need it. :zombies-never-die:

Leave a comment