WSGIServerException: [Errno 8] nodename nor servname provided, or not known


I am getting this error intermittently but when it happens my automated integration testing using Django's LiveServerTestCase comes to a screeching halt throwing the following error:

WSGIServerException: [Errno 8] nodename nor servname provided, or not known

The failure comes as soon as the main test class is instantiated from any given test (this happens after the in-memory db is created and my fixtures are loaded).

My setup is as follows:

  • Mac OSX Snow leopard
  • Django 1.4.1
  • Virtual environment (housing all Python libraries)
  • sqlite (for testing) MySQL/InnoDB for production
  • Local Git branches housing code

So far, this error only occurs while testing on our LAN at my office. At home, tests run just fine but then again tests run fine at my work for a time, hence the intermittent frustration.

In the vein of troubleshooting I have created a new virtualenv, removed all .pyc files system wide, reinstalled MySQL from source as well as all required libraries.

If anyone has come across this error and knows how to beat it, please share.


8/24/2012 1:42:19 AM

Accepted Answer

Sounds like it might be a network issue. Check that you have a consistent internet connection (e.g. by pinging an appropriate server continuously as you run the tests), and that your DNS server is consistently reporting results (e.g. not randomly dropping requests or timing out).

You could also try changing the live server address to a straight IP address (e.g. change localhost to, so that it doesn't have to perform an address lookup.

8/24/2012 2:23:10 AM

I solved this problem by changing this line in /etc/hosts:

# localhost

to localhost

I don't know why the line was commented out.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow