Skip to content
Intermediate / 6 min read

How to Build an IPRoyal Proxy Checker for HTTP, SOCKS5, and Shadowsocks

Learn how to verify IPRoyal proxies with a custom Python script. Check HTTP, SOCKS5, and Shadowsocks endpoints for connectivity, latency, and IP anonymity.

SOCKS5 Web Scraping Privacy/Anonymity Other

Overview

IPRoyal provides residential, datacenter, and ISP proxies with support for HTTP, SOCKS5, and Shadowsocks protocols. Whether you are scraping, monitoring search results, or browsing privately, you need to know that your proxies are alive, fast, and not leaking your real IP. A manual check of each endpoint does not scale. This tutorial shows you how to build a reusable proxy checker in Python that tests connectivity, measures latency, and verifies anonymity for any IPRoyal endpoint.

Prerequisites

  • Python 3.8 or later installed on your system.
  • pip package manager.
  • IPRoyal proxy credentials (host, port, username, password). You can copy these from the IPRoyal dashboard.
  • For Shadowsocks testing: a Shadowsocks client such as shadowsocks-libev (Linux/macOS) or shadowsocks-rust.
  • Basic familiarity with the command line and Python.

Understanding What to Check

A useful proxy checker should answer four questions:

  • Connectivity: Can the proxy reach the public internet?
  • Anonymity: Does the exit IP returned by a service match the proxy IP (not your real IP)?
  • Latency: How long does a request take from start to finish?
  • DNS behavior: Are DNS requests resolved through the proxy or locally? (A leak reveals your real location.)

Different protocols require slightly different handling. The table below summarizes the approach for each IPRoyal protocol.

Protocol Python scheme DNS handling Authentication
HTTP http:// Local or proxy Username/password in URL or header
HTTPS http:// (CONNECT) Local or proxy Username/password in URL or header
SOCKS5 socks5h:// Remote (proxy) Username/password in URL
Shadowsocks Local SOCKS5 after ss-local Remote Password in config

Steps

1. Install Python dependencies

The requests library handles HTTP and HTTPS proxies. For SOCKS5, you also need requests[socks] and pysocks.

pip install requests requests[socks] pysocks

2. Collect your IPRoyal proxy endpoints

Log into the IPRoyal dashboard and copy the proxy list. Most lists include lines in the format:

host:port:username:password

Save the list to a plain text file, for example proxies.txt. If you use a different format, adjust the parsing code in the next steps.

3. Write a basic HTTP proxy checker

Create a file named checker.py. The following snippet tests a single HTTP proxy and prints the returned IP.

import requests
from requests.exceptions import ProxyError, ConnectTimeout

proxy_url = "http://username:password@host:port"
proxies = {
    "http": proxy_url,
    "https": proxy_url,
}

try:
    response = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)
    response.raise_for_status()
    print("Proxy works. Your IP appears as:", response.json()["origin"])
except (ProxyError, ConnectTimeout) as e:
    print("Proxy failed:", e)

Replace username, password, host, and port with your IPRoyal credentials.

4. Extend the checker to SOCKS5

For SOCKS5, change the scheme to socks5h://. The h tells requests to resolve DNS through the proxy, which prevents DNS leaks.

proxy_url = "socks5h://username:password@host:port"
proxies = {
    "http": proxy_url,
    "https": proxy_url,
}

Run the same request block. If you see a Missing dependencies for SOCKS support error, reinstall requests[socks].

5. Add latency measurement and IP verification

Modify the script to time the request and compare the returned IP with the expected proxy IP. You can store the expected IP in your proxy list or fetch it separately.

import time

start = time.time()
response = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)
elapsed = time.time() - start
returned_ip = response.json()["origin"]
print(f"Latency: {elapsed:.2f}s, Returned IP: {returned_ip}")

If the returned IP matches your real IP, the proxy is not anonymizing your traffic. Check your authentication and protocol settings.

6. Test Shadowsocks endpoints

Shadowsocks is a tunnel, not a direct proxy protocol. To check an IPRoyal Shadowsocks endpoint, run a local Shadowsocks client that exposes a SOCKS5 proxy, then test that local SOCKS5 address.

Install shadowsocks-libev on Linux or macOS (via Homebrew). Then create a configuration file ss-local.json:

{
  "server": "your_iproyal_ss_server",
  "server_port": 8388,
  "local_address": "127.0.0.1",
  "local_port": 1080,
  "password": "your_password",
  "method": "aes-256-gcm"
}

Start the client:

ss-local -c ss-local.json

Now treat socks5h://127.0.0.1:1080 as your proxy in the checker script. If the connection works, the Shadowsocks tunnel is functioning.

7. Build a batch checker with rotation and logging

For multiple proxies, parse your proxies.txt file, loop through each endpoint, and log the results to a CSV file. This helps you identify dead IPs and track performance over time.

import csv

with open("proxies.txt") as f:
    lines = [line.strip() for line in f if line.strip()]

results = []
for line in lines:
    host, port, user, pwd = line.split(":")
    proxy_url = f"socks5h://{user}:{pwd}@{host}:{port}"
    proxies = {"http": proxy_url, "https": proxy_url}
    try:
        start = time.time()
        r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)
        elapsed = time.time() - start
        ip = r.json()["origin"]
        results.append((host, port, "OK", f"{elapsed:.2f}", ip))
    except Exception as e:
        results.append((host, port, "FAIL", "", str(e)))

with open("proxy_report.csv", "w", newline="") as f:
    writer = csv.writer(f)
    writer.writerow(["Host", "Port", "Status", "Latency(s)", "Returned IP/Error"])
    writer.writerows(results)

Run the script periodically to maintain a healthy proxy pool.

Troubleshooting

  • 407 Proxy Authentication Required: Verify the username and password. If your password contains special characters like @ or :, URL-encode them (e.g., @ becomes %40).
  • Connection timeout: Check that the host and port are correct and that your IP is whitelisted in the IPRoyal dashboard if required by your plan.
  • SOCKS5 errors: Ensure requests[socks] is installed. Use socks5h:// for remote DNS resolution; socks5:// resolves DNS locally.
  • Shadowsocks client fails to start: Confirm the encryption method matches your IPRoyal configuration, and that the server port is open. Test with ss-local -c ss-local.json -v for verbose output.
  • DNS leaks: Use socks5h:// and test with a DNS leak testing service through the proxy. If the resolver location differs from the proxy location, DNS is leaking.
  • HTTPS certificate errors: Some proxies intercept TLS. For scraping, prefer residential or ISP proxies that support end-to-end HTTPS without interception.

Summary

You have built a Python-based proxy checker that validates HTTP, SOCKS5, and Shadowsocks endpoints from IPRoyal. The script measures latency, verifies the exit IP, and logs results for batch analysis. Regular checks help you rotate out dead proxies and maintain reliable scraping or privacy workflows. IPRoyal's broad protocol support makes it a flexible choice for these tasks, and the checker can be adapted to any provider by changing the proxy list format.