# Connect to a static residential proxy

Access HTTP, HTTPS CONNECT and SOCKS5 using instance endpoints and independent credentials, and describe security and retry boundaries.

Static residential instances deliver the proxy IP, port, username, and password directly. Connects using only the instance information currently displayed on the IP Management page, no longer using rotating residential gateway hosts, sub-accounts, or client whitelists.

## Prepare environment variables

Reads the current IP and port from the example page and injects them separately `STATIC_PROXY_IP`, `STATIC_PROXY_PORT`; Injecting instance username and password from key management system `STATIC_PROXY_USER`, `STATIC_PROXY_PASS`. The following is an example of a desensitization display of the credentials: `ab******9Z` and `p8******K2` The code requires real environment variables to connect. Do not write these values into the source code, command history, and logs.

Detection address below `https://ipinfo.io/json` Return exports `ip`, `country` and `region`(a) which can be used for the initial verification of sample areas. Third-party positioning may be biased.

## HTTP and HTTPS CONNECT

When accessing HTTPS targets using an HTTP proxy, the client establishes a CONNECT tunnel through the proxy:

```bash
curl \
  --proxy "http://${STATIC_PROXY_IP}:${STATIC_PROXY_PORT}" \
  --proxy-user "${STATIC_PROXY_USER}:${STATIC_PROXY_PASS}" \
  --connect-timeout 10 \
  --max-time 30 \
  'https://ipinfo.io/json'
```

When the proxy password contains special characters, the client provides the independent authentication parameters or secure URI encoding capabilities to avoid being misparsed after manually assembled.

## SOCKS5 TCP

Use when the target domain name needs to be resolved by the proxy `socks5h`:

```bash
curl \
  --proxy "socks5h://${STATIC_PROXY_IP}:${STATIC_PROXY_PORT}" \
  --proxy-user "${STATIC_PROXY_USER}:${STATIC_PROXY_PASS}" \
  --connect-timeout 10 \
  --max-time 30 \
  'https://ipinfo.io/json'
```

The current static residential proxies only specifies SOCKS5 TCP access and does not include SOCKS5 UDP.

## Python examples

```python
import os
import requests
from urllib.parse import quote

proxy_url = (
    f"http://{quote(os.environ['STATIC_PROXY_USER'], safe='')}:"
    f"{quote(os.environ['STATIC_PROXY_PASS'], safe='')}@"
    f"{os.environ['STATIC_PROXY_IP']}:"
    f"{os.environ['STATIC_PROXY_PORT']}"
)

response = requests.get(
    "https://ipinfo.io/json",
    proxies={"http": proxy_url, "https": proxy_url},
    timeout=(10, 30),
)
response.raise_for_status()
print(response.json()["ip"])
```

## Connect and try again recommendations

- The connection establishment and read responses are set to timeout separately, and do not allow indefinite waiting.
- If authentication fails, reread the current credentials first, and do not automatically change IP repeatedly.
- Change the IP or modify the credentials, then close the old connection pool and create a connection using the new information on the instance page.
- Stop business requests while instances are being processed for expiration, anomaly, or after-sales operations to avoid making useless retries.
- (a) Do not record the full proxy URL. The logs only retain instance numbers, protocols, timeouts, and desensitization errors.

## Interface boundary

Static residential catalogs, quotes, procurement, orders, examples and after-sales operations are also available through [Static API](/en/developers/api/static-supply) Completed. Whether it is opened depends on the API status in the account console. The automation should use open APIs and securely configured proxy endpoints, not relying on internal console interfaces or browser sessions to capture credentials.

Product concept and purchase process see [First purchase and connection of static residential proxies](/en/help/getting-started/static-residential-quickstart).

html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}
