title: Tor + Urllib2 Python
body: <p>I am trying to use tor to get a new IP every time I access a website: </p>
  
  <pre><code>import socks
  import socket
  socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, '127.0.0.1', 9151, True)
  socket.socket = socks.socksocket
  import urllib2
  print urllib2.urlopen("http://almien.co.uk/m/tools/net/ip/").read()
  </code></pre>
  
  <p>I have also tried port 9150, 9050 too.  </p>
  
  <p>I keep getting: </p>
  
  <pre><code>socks.ProxyConnectionError: Error connecting to SOCKS4 proxy 127.0.0.1:9151: [Errno 61] Connection refused
  </code></pre>