Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A SOCKS reverse proxy server.

Project Description

RSOCKS is a reverse proxy server for transferring traffic of a specific host through a SOCKS 4/5 proxy. It is useful for using SOCKS 4/5 in applications that don’t have SOCKS proxy support.


$ pip install rsocks


$ easy_install rsocks

To upgrade to latest version, you could execute:

$ pip install -U rsocks


First, we need to create a config file with following format:

# /path/to/rsocks.toml
proxy = "socks4://user:pass@"
listen_host =
listen_port = 5025
upstream_host = ""
upstream_port = 25
upstream_ssl = false

There is an example for forwarding SMTP/IMAP of Gmail through a SOCKS5 proxy server:

proxy = "socks5://localhost:1080"
listen_port = 5993
upstream_host = ""
upstream_port = 993
upstream_ssl = true

proxy = "socks5://localhost:1080"
listen_port = 5465
upstream_host = ""
upstream_port = 465
upstream_ssl = true

Next, we start the rsocks server:

$ rsocks --config=/path/to/rsocks.toml
[14:24:44] rsocks.servers.smtp       Using proxy server socks5://localhost:1080
[14:24:44] rsocks.servers.smtp       Listening
[14:24:44] rsocks.servers.imap       Using proxy server socks5://localhost:1080
[14:24:44] rsocks.servers.imap       Listening
[14:24:44] rsocks.pool               Prepared "smtp"
[14:24:44] rsocks.pool               Prepared "imap"
[14:24:44] rsocks.servers.smtp       Starting server...
[14:24:44] rsocks.servers.imap       Starting server...

Don’t stop it now, open your application (such as Airmail in OS X) and set the server option to local forwarding address:

SMTP: without SSL
IMAP: without SSL

Now the application’s traffic will be forwarded through the proxy server (socks5://

If you wish to run the rsocks server in background, please check the Platform Service Templates. For example, OS X users can create com.tonyseek.rsocks.plist file in ~/Library/LaunchAgents and load it as a service:

$ nano ~/.rsocks.toml  # create a config file
$ wget \
      -O ~/Library/LaunchAgents/com.tonyseek.rsocks.plist
$ nano ~/Library/LaunchAgents/com.tonyseek.rsocks.plist  # edit the template
$ launchctl load -w ~/Library/LaunchAgents/com.tonyseek.rsocks.plist

API Overview

There is an example for using API to build a server:

import os

from rsocks.pool import ServerPool
from rsocks.server import ReverseProxyServer

proxy = os.environ.get('SOCKS_PROXY', 'socks5://localhost:1080')
pool = ServerPool()

with pool.new_server(
        upstream=('', 993),
        use_ssl=True) as server:
    server.listen(('', 5993))

with pool.new_server(
        upstream=('', 465),
        use_ssl=True) as server:
    server.listen(('', 5465))

if __name__ == '__main__':

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(9.9 kB) Copy SHA256 Hash SHA256
Wheel py2.py3 Oct 19, 2015
(5.8 kB) Copy SHA256 Hash SHA256
Source None Oct 19, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers