.NET netcore tor C#
Need help with TorSharp?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.


Use Tor for your C# HTTP clients. Tor + Privoxy = :heart:

143 Stars 31 Forks MIT License 161 Commits 7 Opened issues

Services available

Need anything else?


Use Tor for your C# HTTP clients. Tor + Privoxy = :heart:

All you need is client code that can use a simple HTTP proxy.

NuGet version NuGet downloads


OS Status
AppVeyor Windows Build status
Travis CI Linux Build status


This product is produced independently from the Tor® anonymity software and carries no guarantee from The Tor Project about quality, suitability or anything else.


  • Supports:
    • .NET Core (.NET Standard 2.0 and later)
    • .NET Framework (.NET Framework 4.5 and later)
    • Windows
    • ✔️ Windows 10 version 1903
    • Older Windows should work too
    • Linux
    • ✔️ Ubuntu 18.04
    • ✔️ Ubuntu 16.04
    • ✔️ Debian 10
    • ✔️ Debian 9 (confirmed by user)
    • ⚠️ CentOS 7 supported via
      (see below)
    • ❌ Mac OS X support is not planned.
  • Uses Privoxy to redirect HTTP proxy traffic to Tor.
  • Uses virtual desktops to manage Tor and Privoxy processes.
  • Optionally downloads the latest version of Tor and Privoxy.


Install-Package Knapcode.TorSharp


// configure
var settings = new TorSharpSettings
    ZippedToolsDirectory = Path.Combine(Path.GetTempPath(), "TorZipped"),
    ExtractedToolsDirectory = Path.Combine(Path.GetTempPath(), "TorExtracted"),
    PrivoxyPort = 1337,
    TorSocksPort = 1338,
    TorControlPort = 1339,
    TorControlPassword = "foobar"

// download tools await new TorSharpToolFetcher(settings, new HttpClient()).FetchAsync();

// execute var proxy = new TorSharpProxy(settings); var handler = new HttpClientHandler { Proxy = new WebProxy(new Uri("http://localhost:" + settings.PrivoxyPort)) }; var httpClient = new HttpClient(handler); await proxy.ConfigureAndStartAsync(); Console.WriteLine(await httpClient.GetStringAsync("http://api.ipify.org")); await proxy.GetNewIdentityAsync(); Console.WriteLine(await httpClient.GetStringAsync("http://api.ipify.org")); proxy.Stop();


The tool fetcher is throwing an exception. What do I do?

This most likely is happening because the URLs where we fetch Tor or Privoxy from are down or have changed. I would recommend:

  1. Open an issue so I can look into it.

  2. Work around the issue by setting up the tools manually and not using

    . See below.
  3. Investigate the issue yourself. The TorSharp.Sandbox project is helpful for this. Pull requests accepted 🏆.

How do I set up the tools manually?

If you don't want to use the

to download the latest version of the tools for you or if you want to use a specific version of Tor and Privoxy, follow these steps.
  1. Make a directory that will hold the zipped Tor and Privoxy binaries.
  2. Put a Tor Win32 ZIP in that folder with the file name like:
    • {version}
      must be parsable as a
      meaning it is
    • Example:
    • The ZIP is expected to have
  3. Put a Privoxy Win32 ZIP in that folder with a file name like:
    • Again,
      must be parsable as a
    • Example:
    • The ZIP is expected to have
  4. Initialize a
    instance where
    is the directory created above.
  5. Pass this settings instance to the

Privoxy fetched by TorSharp fails to start? Try

On Linux, the Privoxy binaries fetched seem to be built for Debian and Ubuntu distributions. I can confirm that some other distributions don't work. For example, on CentOS 7 the following error appears:

/tmp/TorExtracted/privoxy-linux64-3.0.28/usr/sbin/privoxy: error while loading shared libraries: libpcre.so.3: cannot open shared object file: No such file or directory

I'm no Linux expert but my guess is that the version of PCRE on CentOS 7 vs. Ubuntu is different so at runtime the library can't be found on CentOS. The easiest workaround is to install Privoxy to your system and set the

configuration setting to
(i.e. use Privoxy from PATH).

Note that you may encounter warning or error messages in the output due to new configuration being used with an older executable. I haven't ran into any problems with this myself but it's possible things could get weird.

CentOS 7

Install Privoxy. It is available on

[[email protected]]$ sudo yum install epel-release -y
[[email protected]]$ sudo yum install privoxy -y

Ensure Privoxy is available in PATH.

[[email protected]]$ which privoxy

Set the Privoxy

var settings = new TorSharpSettings();
settings.PrivoxySettings.ExecutablePathOverride = "privoxy";

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.