A module which makes sure all sockets use the TOR proxy at port 9050. Simply add the -mtorify switch to your python commandline.

Source code is available on github.

This module works with both python2 and python3.

When using this module: * Name lookups are blocked. * No UDP traffic is possible. * All TCP traffic is redirected through tor.


  • PySocks
  • TOR, with socks5 proxy at localhost, port 9050

The original SocksiPy (1.0.0) module is no longer being maintained, there are several forks, like PySocks 1.5.7 By Anorov.


torify can be used in two ways, either loaded from the python commandline using the -m switch. Or as an imported module.

From the commandline:

python -mtorify [options] [...with args...]

Several options can be passed to torify:

--proxy PROXY, -p PROXY   Where to find the TOR socks5 proxy
--nocheck, -n             Skip TOR connection check

By default torify uses as the socks proxy for TOR.

As a module

import torify

optionally you can call these function to configure the tor proxy.

torify.set_tor_proxy("", 9150) # use tor from TorBrowser


  • instead of blocking name lookups, resolve names using socks namelookup.


Willem Hengeveld


Comments powered by Disqus