Slow Twitter API calls on Ubuntu 12.04 + Parallels VM

While working on some Python scripts on Ubuntu running on a Parallels VM, I noticed that calls to the Twitter REST api were incredibly slow.  I also saw the same problem when just using curl instead of Python. Oddly, it didn’t occur if I just accessed the url from a browser (Chrome). Even more oddly, it only occurs when accessing the Twitter REST api, not arbitrary websites.

The issue can be avoided by switching the VM from Shared networking to Bridged networking.  The problem and workaround is consistently reproducible for me.

Dev setup:

  • MacBook Pro
  • Parallels Desktop 7.0
  • Ubuntu 12.04
  • Python 2.7.3

import httplib

conn = httplib.HTTPConnection("")
conn.request("GET", "/1/friends/ids.json?screen_name=twitter")
print("status: %d" % conn.getresponse().status)

Shared Networking in Parallels VM:

$ time python
status: 200

real 0m10.135s
user 0m0.028s
sys 0m0.004s

Bridged Networking in Parallels VM

$ time python
status: 200

real 0m0.167s
user 0m0.028s
sys 0m0.012s

The difference is dramatic – the call to conn.request() drops from 10 seconds to a fraction of a second. The above results also hold when just using curl to access the api:

curl --get '' \
     --data 'cursor=-1&screen_name=twitter' --verbose

Strangely, the issue only occurs when accessing the Twitter REST api – it doesn’t occur if you’re fetching other urls, or if you access the Twitter REST url from a browser.

So if you’re doing software development on a Parallels VM, make sure to enable Bridged Networking! (Click on the little web icon in the bottom right of your VM window, or go to Virtual Machine → Configure → Hardware → Network)