19đź‘Ť
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 127.0.0.1 directly is another way round the problem.
9đź‘Ť
None of these posts helped me. In my specific case, Justin Carmony gave me the answer.
Problem
I was mapping [hostname].local to 127.0.0.1 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.
Solution
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.
Example
test.local could become:
- local.test.com
- test.dev
- test.[anything but local]
and your hosts file entry would read:
local.test.com 127.0.0.1
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
4đź‘Ť
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.
- How does use_for_related_fields work in Django?
- Pycharm (Python IDE) doesn't auto complete Django modules
- Celery – No module named five
3đź‘Ť
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.)
2đź‘Ť
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.
- How does this Man-In-The-Middle attack work?
- Sometimes request.session.session_key is None
- How to unit test methods inside django's class based views?
2đź‘Ť
And if all else fails, you can always cProfile your application and see where exactly is the bottleneck.
2đź‘Ť
Had the same problem too, I’ve noticed it with Firefox on Vista and Windows 7 machines. Accessing the development server 127.0.0.1:8000 solved the problem.
- Assign Value of Named URL to a Variable in Django Templates
- Appropriate choice of authentication class for python REST API used by web app
- Use a django built in filter in code (outside of a template)
- Django widget override template
- Managing multiple settings.py files
2đź‘Ť
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.
- TypeError: create_superuser() missing 1 required positional argument: 'profile_picture'
- How can I automatically let syncdb add a column (no full migration needed)
- How does use_for_related_fields work in Django?
- How to make follower-following system with django model
1đź‘Ť
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:
skip-name-resolve
- Django template tag: How to send next_page in {url auth_logout}?
- How can I schedule a Task to execute at a specific time using celery?
- Appropriate choice of authentication class for python REST API used by web app
- Accessing django project in LAN systems
- Python Django custom template tags register.assignment_tag not working
- How to customize django rest auth password reset email content/template
0đź‘Ť
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.
- How do I simulate connection errors and request timeouts in python unit tests
- How can I disable a model field in a django form
- Celery – No module named five
- Installing django 1.5(development version) in virtualenv
- How to clear all session variables without getting logged out
0đź‘Ť
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 127.0.0.1. Use these settings
Include pattern : http://localhost*
Redirect to : http://127.0.0.1$1
Leave the other fields empty.
- Converting a django ValuesQuerySet to a json object
- Django template tag: How to send next_page in {url auth_logout}?
- In python django how do you print out an object's introspection? The list of all public methods of that object (variable and/or functions)?
- Create a canonical "parent" product in Django Oscar programmatically
- Sometimes request.session.session_key is None
0đź‘Ť
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 :/
0đź‘Ť
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
- Django redirect() with anchor (#) parameters
- Django-admin.py startproject opens notepad, instead of creating a project
- Django. Error message for login form
0đź‘Ť
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:
- How does this Man-In-The-Middle attack work?
- Django's get_current_language always returns "en"
- Assign Value of Named URL to a Variable in Django Templates