# How Proxy Configuration Works in Sherlock: Supported URL Formats and CLI Usage

> Learn how Sherlock configures proxies using supported URL formats like HTTP HTTPS and SOCKS45 via the --proxy CLI option for efficient request routing.

- Repository: [Sherlock/sherlock](https://github.com/sherlock-project/sherlock)
- Tags: how-to-guide
- Published: 2026-03-02

---

**Sherlock routes all HTTP requests through a proxy specified via the `--proxy` (or `-p`) command-line option, supporting any URL scheme that Python's `requests` library accepts, including HTTP, HTTPS, and SOCKS4/5.**

The sherlock-project/sherlock tool provides built-in **proxy configuration** to help users route username lookup requests through intermediary servers. Whether you need to bypass regional restrictions or avoid IP-based rate limiting, understanding how Sherlock handles proxies ensures you can scan securely and anonymously.

## Command-Line Proxy Interface

The primary entry point for proxy configuration is the `--proxy` argument, defined in the argument parser within [`sherlock_project/sherlock.py`](https://github.com/sherlock-project/sherlock/blob/main/sherlock_project/sherlock.py). According to the source code at lines 594–600, the CLI accepts the following option:

```text
--proxy PROXY_URL, -p PROXY_URL
Make requests over a proxy. e.g. socks5://127.0.0.1:1080

```

When provided, this value propagates through the application to every HTTP request Sherlock makes during the username enumeration process.

## Proxy Implementation in the Request Layer

Inside the main `sherlock()` function, the tool checks whether a proxy string was supplied and constructs a dictionary compatible with Python's `requests` library. As implemented at lines 313–319 of [`sherlock_project/sherlock.py`](https://github.com/sherlock-project/sherlock/blob/main/sherlock_project/sherlock.py), the conditional logic follows this pattern:

```python
if proxy is not None:
    proxies = {"http": proxy, "https": proxy}
    future = request(
        url=url_probe,
        headers=headers,
        proxies=proxies,
        …
    )
else:
    future = request(
        url=url_probe,
        headers=headers,
        …
    )

```

This approach ensures that both HTTP and HTTPS requests route through the specified proxy endpoint without modifying the underlying request semantics.

## Supported Proxy URL Formats

Sherlock does not implement custom proxy parsing; it delegates all proxy handling directly to the `requests` library. Consequently, any proxy URL format that `requests` (and its optional `socks` extra) understands is valid:

- **HTTP proxies**: `http://host:port`
- **HTTPS proxies**: `https://host:port`  
- **SOCKS4/5 proxies**: `socks4://host:port` or `socks5://host:port`

Note that SOCKS proxy support requires the `requests[socks]` package, which is included as a standard dependency in Sherlock's installation. The official documentation in [`docs/README.md`](https://github.com/sherlock-project/sherlock/blob/main/docs/README.md) (lines 88–90) provides the canonical example: `socks5://127.0.0.1:1080`.

## Usage Examples

### Routing Through a SOCKS5 Proxy

To run Sherlock through a local SOCKS5 proxy listening on port 1080:

```bash
python -m sherlock_project.sherlock \
    --proxy socks5://127.0.0.1:1080 \
    username

```

### Using an HTTP Proxy

For corporate environments or caching proxy servers:

```bash
python -m sherlock_project.sherlock \
    -p http://proxy.example.com:3128 \
    user123

```

### Programmatic Configuration

When importing Sherlock as a Python library, pass the proxy string directly to the `proxy` parameter of the `sherlock()` function:

```python
from sherlock_project.sherlock import sherlock
from sherlock_project.sites import SitesInformation

sites = SitesInformation()
results = sherlock(
    username="alice",
    site_data=sites.sites,
    query_notify=MyNotify(),
    proxy="socks5://127.0.0.1:1080",
)

```

## User Feedback and Confirmation

Before initiating scans, Sherlock confirms active proxy configuration to prevent accidental direct connections. In the `main()` function at lines 625–627 of [`sherlock_project/sherlock.py`](https://github.com/sherlock-project/sherlock/blob/main/sherlock_project/sherlock.py), the tool prints:

```python
if args.proxy is not None:
    print("Using the proxy: " + args.proxy)

```

This transparency helps users verify that their traffic will route through the intended intermediary rather than their direct IP address.

## Summary

- **Command-line interface**: Use `--proxy` or `-p` followed by a URL in [`sherlock_project/sherlock.py`](https://github.com/sherlock-project/sherlock/blob/main/sherlock_project/sherlock.py) (lines 594–600).
- **Request handling**: The `sherlock()` function injects proxies into all requests via a dictionary mapping both HTTP and HTTPS to the provided URL (lines 313–319).
- **Format support**: Any URL scheme accepted by Python's `requests` library works, including `http://`, `https://`, and `socks5://` (requires `requests[socks]`).
- **Library usage**: Pass the proxy string directly to the `proxy` parameter when calling `sherlock()` programmatically.
- **Visual confirmation**: The CLI prints the active proxy before scanning begins (lines 625–627).

## Frequently Asked Questions

### What proxy formats does Sherlock support?

Sherlock supports any proxy URL format that Python's `requests` library accepts, including HTTP (`http://host:port`), HTTPS (`https://host:port`), and SOCKS4/5 (`socks4://host:port` or `socks5://host:port`). SOCKS support requires the `requests[socks]` dependency, which is installed by default with Sherlock.

### How do I use a SOCKS5 proxy with Sherlock from the command line?

Use the `--proxy` or `-p` flag followed by your SOCKS5 URL. For example: `python -m sherlock_project.sherlock --proxy socks5://127.0.0.1:1080 username`. This routes all username lookup requests through the specified SOCKS5 endpoint as confirmed in [`sherlock_project/sherlock.py`](https://github.com/sherlock-project/sherlock/blob/main/sherlock_project/sherlock.py).

### Can I configure a proxy when using Sherlock as a Python library?

Yes. When calling the `sherlock()` function programmatically, pass the proxy URL string to the `proxy` parameter. The function constructs the appropriate `proxies` dictionary and applies it to every HTTP request made during the scan according to the logic at lines 313–319.

### Does Sherlock require additional dependencies for SOCKS proxy support?

SOCKS proxy support is available through the `requests[socks]` package, which is listed as a standard dependency in Sherlock's installation requirements. If you installed Sherlock via pip, SOCKS support is already included and ready for use with `socks5://` URLs.