2026-10-27 · VeilSocks

What you need before you start

Routing Python through a mobile proxy is three facts: the endpoint host and port, your username and password, and which protocol it speaks — SOCKS5 or HTTP(S). If you are unsure which to pick, the short version is that SOCKS5 tunnels anything while HTTP(S) is web-only; the long version is in SOCKS5 vs HTTP proxy. Everything below works with either; the only thing that changes is the URL scheme.

Use legitimate workloads only: public-data scraping, QA across regions, SERP and price monitoring, ad verification, brand protection. Mobile IPs are shared carrier addresses, so treat the targets with the same restraint you would from your own office network.

The fastest path: VeilSocks Connect + localhost

The simplest setup skips credentials in your code entirely. The VeilSocks Connect desktop app terminates to the mobile backend and exposes a plain 127.0.0.1:PORT endpoint. Python then points at localhost, and the remote carrier IP lives one layer behind that:

`` proxies = {"http": "socks5h://127.0.0.1:1080", "https": "socks5h://127.0.0.1:1080"} ``

No password in your scripts, no secret in your shell history. For servers and CI where a desktop app is awkward, use the direct endpoint with auth instead, shown next.

requests: one session, correct DNS

Install the SOCKS extra first: pip install "requests[socks]". The detail that trips most people up is DNS. Use the socks5h scheme (the h means "resolve the hostname on the proxy side") so your laptop's resolver never sees the target.

``` import requests

proxies = { "http": "socks5h://user:pass@proxy.veilsocks.com:1080", "https": "socks5h://user:pass@proxy.veilsocks.com:1080", } r = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=30) print(r.json()) ```

Reuse a requests.Session() so connections pool and cookies persist across a crawl. Keep the credentials in environment variables, not in the file — a proxy URL pasted into a repo or a screenshot is the most common way people leak access.

Scrapy: proxy middleware the clean way

Scrapy reads a per-request proxy meta key, so you can set it once in a middleware or in start_requests. For a whole-project default, set it in the spider:

``` class PricesSpider(scrapy.Spider): name = "prices" custom_settings = {"CONCURRENT_REQUESTS": 8, "DOWNLOAD_DELAY": 1.0}

def start_requests(self): meta = {"proxy": "http://user:pass@proxy.veilsocks.com:8080"} for url in self.urls: yield scrapy.Request(url, meta=meta, callback=self.parse) ```

Scrapy's built-in HttpProxyMiddleware handles the http:// and https:// schemes directly. For SOCKS5 in Scrapy, front the proxy with a localhost HTTP endpoint from Connect, or use an http-to-socks shim — Scrapy's native proxy support is HTTP-shaped. Keep CONCURRENT_REQUESTS modest on a single mobile IP; one radio uplink is not a datacenter pipe.

Playwright: browser automation through the proxy

For anything that needs a real browser — JavaScript-heavy pages, ad verification, login QA — Playwright takes the proxy as a launch option:

``` from playwright.sync_api import sync_playwright

with sync_playwright() as p: browser = p.chromium.launch(proxy={ "server": "http://proxy.veilsocks.com:8080", "username": "user", "password": "pass", }) page = browser.new_page() page.goto("https://api.ipify.org?format=json") print(page.inner_text("body")) browser.close() ```

Chromium through Playwright resolves DNS remotely by default when the proxy carries the request, so you get the mobile exit IP without a local leak. Pair it with a realistic viewport and a plausible locale so your automated browser looks like the device the carrier IP implies.

Verify the exit IP every run

Never assume the proxy is live — prove it. At the start of a job, fetch your IP through the proxy from an IP-echo service, confirm it falls in a mobile carrier range, and then check if the IP is blacklisted on the lists that matter to your target. A thirty-second preflight saves you from a crawl that quietly ran from your own office address, or from a burned IP that returns nothing but CAPTCHAs.

Because VeilSocks runs on genuine SIM cards, the exit address is a real carrier range — see how we count our pool for what that means in practice and why it behaves differently from recycled datacenter blocks.

Rotation, retries and being a good citizen

Mobile IPs rotate naturally as the carrier reassigns addresses, and you can trigger a fresh IP on demand. In code, lean on that instead of hammering: on a 403 or a CAPTCHA, back off, request a new IP, and retry with jitter rather than looping instantly. Cap concurrency per IP, respect robots.txt and rate limits, and cache aggressively so you are not re-fetching pages you already have. Clean carrier IPs are a renewable resource only if you treat targets politely; the fastest way to get a range throttled is to behave like a flood. If you are still deciding whether mobile is the right class of proxy at all, what a mobile proxy actually is is the two-minute background read.

Bottom line

Python plus a mobile proxy is a four-line change once the basics are right: pick the scheme, resolve DNS on the proxy side, keep credentials out of your code, and verify the exit IP before every run. Real 4G/5G mobile proxies from VeilSocks expose both SOCKS5 and HTTP(S) against the same pool, so the same script works whichever your tooling prefers.

FAQ

Q: Do I need SOCKS5 or HTTP to use a mobile proxy in Python? Either works. requests, Scrapy and Playwright all support both. Use socks5h:// for SOCKS5 with remote DNS, or http:// for the HTTP front-end. SOCKS5 is the safer default if your pipeline includes non-browser tools.

Q: Why use socks5h instead of socks5 in the proxy URL? The h tells the client to resolve the target hostname on the proxy side. Plain socks5 resolves locally first, which leaks every target to your own DNS resolver. Always prefer socks5h for scraping.

Q: How do I rotate the mobile IP from Python? Mobile IPs rotate as the carrier reassigns them, and you can request a fresh one on demand. In code, trigger a rotation on repeated blocks or CAPTCHAs, then retry with a short randomized delay instead of looping immediately.

Q: How do I keep my proxy credentials out of my code? Read them from environment variables or a secrets file, never hard-code them. Simpler still, use the VeilSocks Connect desktop app so Python points at a localhost endpoint and no password ever touches your script.

Q: How do I confirm my requests are actually going through the proxy? Fetch your IP through the proxy from an IP-echo service at the start of each run and confirm it is a mobile carrier range, not your own address. Then check that IP against the blacklists relevant to your target before the real crawl begins.

Real 4G/5G mobile proxies, your GB never expire

Genuine US carrier SIM IPs — SOCKS5 & HTTP, pay per GB, instant activation.

Create your account →