Skip to content
Beginner / 7 min read

How to Authenticate Smartproxy Proxies: IP Whitelisting vs Username/Password and Sticky Sessions

Decide between username/password and IP-whitelist authentication, pick rotating or sticky sessions, and verify your Smartproxy residential or datacenter endpoint with real HTTP and SOCKS5 requests before you automate anything.

HTTP(S) Privacy/Anonymity Other

Overview

Smartproxy provides residential and datacenter proxy endpoints over HTTP(S) and SOCKS5 (65M+ IPs on the residential side) on a flat monthly plan. Two early decisions determine whether your setup works on the first try: which authentication mode you use, and whether a request should keep the same exit IP or rotate to a new one.

This guide covers both decisions and verifies them with real command-line requests, so you can confirm the endpoint works before wiring it into a scraper, a rank tracker, or a browser profile.

Authentication: username/password or IP whitelist

Both authentication styles are configured in the dashboard:

  • Username/password — credentials are sent with every request. Works from any machine, container, or CI runner, and survives a change of network or ISP address.
  • IP whitelist — no credentials travel with the request, but your current public IP must be registered. It stops working the moment your ISP rotates your address or you move to another network.

Use username/password unless you have a fixed office IP and a tool that cannot send proxy credentials at all.

Session types: rotating or sticky

  • Rotating — requests can leave from a different IP each time. This is the behaviour when no session token is attached, and it is what you want for large-scale collection where per-IP request counts must stay low.
  • Sticky — the same exit IP is held for the lifetime of a session token, which keeps stateful flows such as login, add-to-cart, and checkout on one address.

Smartproxy encodes session and targeting details in the proxy username. The exact parameter syntax is generated for you and can change, so always copy the ready-made string from the dashboard endpoint generator instead of typing it from memory. The examples below show the general shape only.

Choosing between residential and datacenter endpoints

Residential Datacenter
Pool 65M+ IPs Smaller, stable ranges
Speed Moderate Fast
Best for Geo-accurate collection, ad verification, price checks High-volume crawling of tolerant targets, internal testing
Blocking risk Lower, IPs are widely distributed Higher, ranges are well known

Both endpoint types are reached the same way; only the host, port, and credentials differ.

Steps

  1. Locate your endpoint and credentials in the dashboard.

    Log in, open the proxy setup page for the product you purchased, and copy the endpoint host and port, your proxy username and password, and any session or targeting string the generator injects into the username.

    export SP_USER='your-proxy-username'
    export SP_PASS='your-proxy-password'
    export SP_ENDPOINT='host:port'   # paste the exact value from the dashboard
    

    Keep credentials in environment variables or a secrets manager rather than committing them to a script.

  2. Choose your authentication mode.

    Username/password is the default recommendation. If you prefer whitelisting instead, note your current public IP and add it in the dashboard authentication settings.

    curl -sS https://ipinfo.io/ip
    

    Re-check and re-add this address whenever your ISP changes it; a stale whitelist entry is the most common cause of a sudden 407 error.

  3. Verify a rotating HTTP request.

    Send a request through the endpoint and confirm you see a proxy IP rather than your own.

    curl -sS -x "http://${SP_USER}:${SP_PASS}@${SP_ENDPOINT}" https://ipinfo.io/json
    

    Run it several times in a loop to confirm the exit IP actually changes between requests.

    for i in 1 2 3; do
      curl -sS -x "http://${SP_USER}:${SP_PASS}@${SP_ENDPOINT}" https://ipinfo.io/ip
      echo
    done
    

    If the address never changes, check whether a session token is still embedded in your username.

  4. Pin an exit IP with a sticky session.

    Copy the sticky-session username from the dashboard generator (it is your username plus a session identifier) and export it under a separate variable so you can switch between the rotating and sticky strings without editing the credentials themselves.

    export SP_USER_STICKY='your-username-with-session-parameters'   # copy from the dashboard
    
    for i in 1 2 3; do
      curl -sS -x "http://${SP_USER_STICKY}:${SP_PASS}@${SP_ENDPOINT}" https://ipinfo.io/ip
      echo
    done
    

    All three responses should show the same exit IP for the lifetime of that session token.

  5. Test geo-targeting.

    Country, city, and state targeting are also passed through the generated username string. Confirm the request lands where you expect before you build a per-market workflow on top of it.

    export SP_USER_DE='your-username-with-country-parameter'   # copy from the dashboard
    curl -sS -x "http://${SP_USER_DE}:${SP_PASS}@${SP_ENDPOINT}" https://ipinfo.io/json
    

    The country field in the response should match the target you configured.

  6. Test the SOCKS5 endpoint.

    Use the socks5h:// scheme so DNS resolution happens at the proxy rather than locally, which prevents leaks and DNS-based blocks.

    curl -sS -x "socks5h://${SP_USER}:${SP_PASS}@${SP_ENDPOINT}" https://ipinfo.io/json
    

    If your client only supports socks5://, DNS is resolved locally; prefer socks5h in scripts.

  7. Switch to a datacenter endpoint when throughput matters.

    Datacenter credentials and hosts are listed separately in the dashboard. Re-run the verification loop against the datacenter host and port; only the endpoint values change, not the request format.

    export SP_DC_ENDPOINT='datacenter-host:port'
    curl -sS -x "http://${SP_USER}:${SP_PASS}@${SP_DC_ENDPOINT}" https://ipinfo.io/ip
    
  8. Use the endpoint from Python.

    Reuse the same environment variables so nothing changes when you move from the shell to a script.

    import os
    import requests
    
    auth = f"{os.environ['SP_USER']}:{os.environ['SP_PASS']}@"
    endpoint = os.environ['SP_ENDPOINT']
    proxies = {
        "http": f"http://{auth}{endpoint}",
        "https": f"http://{auth}{endpoint}",
    }
    
    response = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=30)
    response.raise_for_status()
    print(response.json())
    

    For sticky work, build a second proxies dictionary from SP_USER_STICKY and use it for the whole session.

  9. Add retry and rotation logic.

    Handle 429 and 5xx responses with a short exponential backoff, and let rotating sessions supply a new IP naturally on each attempt instead of retrying the same session repeatedly.

    import time
    
    for attempt in range(4):
        try:
            response = requests.get("https://ipinfo.io/json", proxies=proxies, timeout=30)
            if response.status_code < 400:
                break
        except requests.RequestException:
            pass
        time.sleep(2 ** attempt)
    

Troubleshooting

  • 407 Proxy Authentication Required — the username or password is wrong, a session or targeting string was pasted into the wrong field, or your whitelisted IP no longer matches your current address. Re-copy the string from the dashboard generator.
  • Credentials rejected after working fine — passwords containing @, :, /, or # must be URL-encoded inside the proxy URL (@ becomes %40, : becomes %3A). Prefer a password without special characters if your tool cannot encode them.
  • curl: (7) Failed to connect — the host or port is wrong, or you copied a residential endpoint into a datacenter slot (or the reverse). Each product has its own host and port.
  • Every request returns the same IP — a sticky session token is still present in the username, or you are using the sticky credential set instead of the rotating one.
  • Sticky session changes IP mid-workflow — session lifetimes expire. Start a new session token deliberately and re-authenticate rather than assuming the old one persists indefinitely.
  • Requests time out only on SOCKS5 — the client may not support remote DNS. Switch to socks5h:// or fall back to the HTTP endpoint for that tool.
  • Whitelist authentication fails intermittently — mobile networks and home connections rotate public IPs. Use username/password for unattended jobs.

Summary

Smartproxy onboarding comes down to two choices and one habit. Choose username/password unless you have a genuinely static IP, and choose rotating sessions for collection workloads or sticky sessions for stateful flows. The habit is copying the endpoint and username string straight from the dashboard generator, because the session and geo-targeting parameters live in that string. Verify the rotating path, the sticky path, the SOCKS5 path, and the datacenter host with the short curl loops above before pointing a scraper or rank tracker at them.