IPRoyal configures its residential proxies differently from most providers: the username stays untouched and every option, from the country to the sticky session, is appended to the password. This guide uses that format to pass an IPRoyal proxy to NSLSolver, so that Kasada x-kpsdk headers, Akamai _abck cookies and Cloudflare cf_clearance cookies are earned on the IP your own requests then leave from, in Python and Node.js.
NSLSolver solves on its servers without a browser and bills only successful solves. Cloudflare Challenge, reCAPTCHA v3 and Akamai require a proxy, because the token or cookie belongs to the IP that earned it. IPRoyal's _killswitch-1 flag is particularly useful here: it makes a lost sticky IP visible instead of silently replacing it.
IPRoyal residential proxy format at a glance
- Gateway
- geo.iproyal.com:12321 (HTTP/HTTPS), :32325 (SOCKS5)
- Authentication
- USERNAME:PASSWORD_<option>_<option>...
- Sticky session
- _session-<exactly 8 alphanumeric characters>
- Session length
- _lifetime-30m (1 second to 7 days, one unit)
- Geo-targeting
- _country-gb _city-london _state-california (with _country-us) _region-europe
- Full example
- http://USERNAME:PASSWORD_country-gb_session-a1b2c3d4_lifetime-30m@geo.iproyal.com:12321
From IPRoyal's residential proxy documentation (docs.iproyal.com), checked 1 December 2026. USERNAME and PASSWORD are your proxy credentials from the IPRoyal dashboard.
Which NSLSolver solves need an IPRoyal proxy?
Pass the IPRoyal proxy URL in the proxy field of POST https://api.nslsolver.com/solve and send your own requests through the very same URL. Because the session lives in the password, any change to the password string, even the order of the options, can mean a different session.
| Solve type | Proxy | What is bound to the IP | NSLSolver price per 1,000 |
|---|---|---|---|
| Cloudflare Challenge | Required | cf_clearance cookie | $1.00 |
| Akamai Bot Manager (beta) | Required | _abck and bm_sz cookies | $2.00 |
| reCAPTCHA v3 | Required | The score depends on the IP | $1.00 |
| Kasada | Optional, recommended | The x-kpsdk-ct session | $1.50 |
| Cloudflare Turnstile | Optional (proxyless by default) | Nothing by default | $0.80 |
Only successful solves are billed. IPRoyal bills its proxy traffic separately, under your IPRoyal plan.
How IPRoyal's password-based targeting works
IPRoyal residential proxies leave the username alone. Options are appended to the password as _key-value pairs: PASSWORD_country-gb_session-a1b2c3d4_lifetime-30m. Without _session, every request rotates to a new IP. geo.iproyal.com picks a nearby gateway region automatically; IPRoyal also lists regional hosts such as us.proxy.iproyal.com and sg.proxy.iproyal.com on the same ports.
Two rules trip people up. The session value must be a random alphanumeric string of exactly 8 characters, so a UUID or a worker name will not do. And _lifetime takes a single unit, between 1 second and 7 days: 30m or 2h works, a combined value such as 1h30m does not.
| Option | Example | Notes from IPRoyal's docs |
|---|---|---|
| _country- | _country-gb | Lowercase ISO code. A comma list (_country-dk,it,ie) picks one at random. |
| _city- | _city-london | Set the country as well. |
| _state- | _state-california | US only, together with _country-us. |
| _region- | _region-europe | Broad regions such as europe or northamerica. |
| _session- | _session-a1b2c3d4 | Exactly 8 alphanumeric characters; keeps one IP. |
| _lifetime- | _lifetime-30m | From 1 second to 7 days, one unit only. |
| _killswitch-1 | _killswitch-1 | Returns HTTP 410 instead of rotating when the sticky IP becomes unavailable. |
IPRoyal also documents _forcerandom-1 and IP whitelisting (set in the dashboard, then connect with host:port only).
Sticky sessions, the killswitch and cf_clearance replay
cf_clearance is accepted only from the IP that earned it, for the site's Challenge Passage window (30 minutes by default). Akamai's _abck behaves the same way, and Kasada expects the x-kpsdk-ct session to stay on one IP. So every flow in this guide uses an IPRoyal sticky session, with a lifetime at least as long as you will reuse the result: _lifetime-30m matches the default Challenge Passage.
By default, when a sticky IP goes away, IPRoyal quietly gives the session another one. For IP-bound cookies that is the worst case: your next request carries a cookie from an IP that never earned it, and the site answers with a challenge or a 403. With _killswitch-1 the gateway answers HTTP 410 instead, so the code below catches the error, opens a new session and solves again.
Geography should stay constant too. Keep the same _country (and _city, if you set one) for the solve and the replay, and for Cloudflare Challenge pass an accept_language that fits that country. A random-country list such as _country-dk,it,ie is fine for rotating traffic but works against a consistent identity in a sticky session.
Python: cf_clearance on an IPRoyal session with the killswitch
IPRoyalClearance keeps one sticky session and its cookie, renews both when the killswitch fires or when Cloudflare challenges again, and otherwise reuses the same IP, cookie and User-Agent. secrets.token_hex(4) produces the 8 characters IPRoyal requires.
# iproyal_nslsolver.py (pip install curl_cffi)
import secrets
from curl_cffi import requests
NSL_API_KEY = "nsl_YOUR_API_KEY"
IPROYAL_USERNAME = "YOUR_IPROYAL_USERNAME"
IPROYAL_PASSWORD = "YOUR_IPROYAL_PASSWORD"
UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36")
def iproyal_proxy(country="gb", session=None, lifetime="30m", killswitch=True):
"""IPRoyal residential: every option is appended to the PASSWORD with
underscores. _session- must be exactly 8 alphanumeric characters; without
it, each request gets a new IP."""
password = f"{IPROYAL_PASSWORD}_country-{country}"
if session:
password += f"_session-{session}_lifetime-{lifetime}" # one unit: 30m, 2h...
if killswitch:
password += "_killswitch-1" # 410 instead of a silent IP swap
return f"http://{IPROYAL_USERNAME}:{password}@geo.iproyal.com:12321"
def solve(payload):
r = requests.post("https://api.nslsolver.com/solve",
headers={"X-API-Key": NSL_API_KEY}, json=payload, timeout=180)
data = r.json()
if r.status_code != 200 or not data.get("success"):
raise RuntimeError(f"NSLSolver {r.status_code}: {data.get('error', data)}")
return data
def browser_session(proxy, user_agent, accept_language=None, impersonate="chrome"):
# TLS fingerprint must match the UA: "chrome" for a Chrome UA, "safari_ios"
# for the iPhone Safari UA that a Challenge solve returns
s = requests.Session(impersonate=impersonate)
s.proxies = {"http": proxy, "https": proxy}
s.headers["User-Agent"] = user_agent
if accept_language:
s.headers["Accept-Language"] = accept_language
return s
def is_challenge(resp):
return resp.headers.get("cf-mitigated") == "challenge" or (
resp.status_code in (403, 503) and "Just a moment..." in resp.text[:5000])
class IPRoyalClearance:
"""One sticky IPRoyal session and the cf_clearance earned on it. With
_killswitch-1 a lost IP surfaces as an error (HTTP 410, reported by curl as
a failed CONNECT for https URLs), so we renew instead of sending a cookie
from an IP that never earned it."""
def __init__(self, url, site_key, country="gb", lang="en-GB,en;q=0.9"):
self.url, self.site_key, self.country, self.lang = url, site_key, country, lang
self.renew()
def renew(self):
self.proxy = iproyal_proxy(self.country, session=secrets.token_hex(4)) # 8 chars
cf = solve({"type": "challenge", "url": self.url, "site_key": self.site_key,
"proxy": self.proxy, "accept_language": self.lang})
self.s = browser_session(self.proxy, cf["user_agent"], self.lang, impersonate="safari_ios")
for name, value in cf["cookies"].items(): # cf_clearance
self.s.cookies.set(name, value)
def get(self, url):
try:
r = self.s.get(url)
except Exception as exc:
if "410" not in str(exc):
raise
self.renew() # the sticky IP is gone: new session, new solve
return self.s.get(url)
if is_challenge(r): # cookie expired or rejected
self.renew()
r = self.s.get(url)
return r
cf = IPRoyalClearance("https://cf-protected.example.com/", "0x4AAAAAAA...")
for page in range(1, 6):
print(page, cf.get(f"https://cf-protected.example.com/catalog?page={page}").status_code)Python: Kasada x-kpsdk headers through IPRoyal
Kasada calls are short, so a 10-minute lifetime is enough here. Take p_js_path, fp_host and tl_host from the browser's Network tab, and send the returned headers through the same session with the same User-Agent.
# Same file: Kasada headers on an 8-character IPRoyal session.
kasada_proxy = iproyal_proxy("gb", session=secrets.token_hex(4), lifetime="10m")
k = solve({
"type": "kasada",
"url": "https://www.kasada-site.example.com/login",
"user_agent": UA,
"ua_version": 145,
"kasada_config": {
"p_js_path": "/<uuid-1>/<uuid-2>/p.js", # the target's real p.js path (DevTools > Network)
"fp_host": "www.kasada-site.example.com", # host serving /fp
"tl_host": "api.kasada-site.example.com", # host receiving POST /tl
},
"proxy": kasada_proxy,
})
api = browser_session(kasada_proxy, UA)
r = api.post("https://api.kasada-site.example.com/v1/search",
headers=k["headers"], json={"q": "..."})
print(r.status_code) # x-kpsdk-cd is single-use: solve again for the next callPython: Akamai _abck cookies through IPRoyal
This example adds _city-london to show city targeting. Replay all returned cookies, not only _abck, with the same User-Agent. Akamai is in beta on NSLSolver.
# Same file: Akamai cookies on a city-targeted IPRoyal session.
def iproyal_city_proxy(country, city, session, lifetime="30m"):
password = (f"{IPROYAL_PASSWORD}_country-{country}_city-{city}"
f"_session-{session}_lifetime-{lifetime}_killswitch-1")
return f"http://{IPROYAL_USERNAME}:{password}@geo.iproyal.com:12321"
akamai_proxy = iproyal_city_proxy("gb", "london", secrets.token_hex(4))
ak = solve({
"type": "akamai",
"url": "https://akamai-site.example.com/login",
"user_agent": UA,
"proxy": akamai_proxy, # required for akamai
})
shop = browser_session(akamai_proxy, UA, "en-GB,en;q=0.9")
for name, value in ak["cookies"].items(): # _abck, bm_sz, ...
shop.cookies.set(name, value)
r = shop.get("https://akamai-site.example.com/api/products")
print(r.status_code) # 403 "Access Denied" = solve againNode.js: the same flows with undici
Because the options live in the password, encode it with encodeURIComponent before putting it in the URL. undici's ProxyAgent decodes the credentials and sends them to the gateway.
// iproyal-nslsolver.mjs (Node 18+, npm i undici)
import { randomBytes } from "node:crypto";
import { fetch, ProxyAgent } from "undici";
const NSL_API_KEY = "nsl_YOUR_API_KEY";
const IPROYAL_USERNAME = "YOUR_IPROYAL_USERNAME";
const IPROYAL_PASSWORD = "YOUR_IPROYAL_PASSWORD";
const UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
"(KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36";
// Options go in the PASSWORD. randomBytes(4) -> 8 hex characters, as IPRoyal requires.
function iproyalProxy({ country = "gb", lifetime = "30m" } = {}) {
const session = randomBytes(4).toString("hex");
const password = IPROYAL_PASSWORD + "_country-" + country + "_session-" + session +
"_lifetime-" + lifetime + "_killswitch-1";
return "http://" + IPROYAL_USERNAME + ":" + encodeURIComponent(password) + "@geo.iproyal.com:12321";
}
async function solve(payload) {
const res = await fetch("https://api.nslsolver.com/solve", {
method: "POST",
headers: { "X-API-Key": NSL_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
const data = await res.json();
if (!res.ok || !data.success) {
throw new Error("NSLSolver " + res.status + ": " + (data.error || JSON.stringify(data)));
}
return data;
}
const cookieHeader = (cookies) =>
Object.entries(cookies).map(([k, v]) => k + "=" + v).join("; ");
// 1) Cloudflare Challenge from a UK sticky IP
const cfProxy = iproyalProxy({ country: "gb" });
const cf = await solve({
type: "challenge",
url: "https://cf-protected.example.com/",
site_key: "0x4AAAAAAA...",
proxy: cfProxy,
accept_language: "en-GB,en;q=0.9",
});
const page = await fetch("https://cf-protected.example.com/catalog", {
dispatcher: new ProxyAgent(cfProxy),
headers: { "User-Agent": cf.user_agent, "Accept-Language": "en-GB,en;q=0.9", Cookie: cookieHeader(cf.cookies) },
});
console.log("challenge", page.status);
// With _killswitch-1, a lost sticky IP makes fetch() throw (proxy answered 410):
// catch it, build a new iproyalProxy() and solve again.
// 2) Kasada
const kProxy = iproyalProxy({ country: "gb", lifetime: "10m" });
const k = await solve({
type: "kasada",
url: "https://www.kasada-site.example.com/login",
user_agent: UA,
ua_version: 145,
kasada_config: {
p_js_path: "/<uuid-1>/<uuid-2>/p.js", // the target's real p.js path (DevTools > Network)
fp_host: "www.kasada-site.example.com", // host serving /fp
tl_host: "api.kasada-site.example.com", // host receiving POST /tl
},
proxy: kProxy,
});
const api = await fetch("https://api.kasada-site.example.com/v1/search", {
method: "POST",
dispatcher: new ProxyAgent(kProxy),
headers: { ...k.headers, "User-Agent": UA, "Content-Type": "application/json" },
body: JSON.stringify({ q: "..." }),
});
console.log("kasada", api.status);
// 3) Akamai
const akProxy = iproyalProxy({ country: "gb" });
const ak = await solve({ type: "akamai", url: "https://akamai-site.example.com/login", user_agent: UA, proxy: akProxy });
const products = await fetch("https://akamai-site.example.com/api/products", {
dispatcher: new ProxyAgent(akProxy),
headers: { "User-Agent": UA, Cookie: cookieHeader(ak.cookies) },
});
console.log("akamai", products.status);
// Node's fetch does not copy Chrome's TLS fingerprint; if a strict site still
// blocks it, send the follow-up requests from Python with curl_cffi.Troubleshooting IPRoyal with NSLSolver
For the meaning of each NSLSolver status code and of the Cloudflare, Kasada and Akamai errors, see the anti-bot error-code reference.
| Symptom | Likely cause | Fix |
|---|---|---|
| Session does not stick | The _session value is not exactly 8 alphanumeric characters. | Generate it with secrets.token_hex(4) or randomBytes(4).toString("hex"). |
| 407 Proxy Authentication Required | Options were added to the username instead of the password. | Keep the username plain and append _country-..., _session-... to the password. |
| HTTP 410 from the proxy | _killswitch-1 is set and the sticky IP became unavailable. | Open a new session and solve again; the old cookie cannot be used. |
| Lifetime ignored | Two units combined, such as 1h30m. | Use one unit: 90m. |
| NSLSolver 400 Validation failed | Proxy without a scheme, or a missing required field. | Send the full http:// URL and check the field named in the error. |
| NSLSolver 503 Solve failed | The solve did not complete; it is not billed. | Retry with backoff; if it repeats on one session, open a new one. |
Related
- Anti-bot error-code reference: Cloudflare, Kasada, Akamai and NSLSolver errors with fixes.
- The cf_clearance cookie: what it is bound to and how long it lasts.
- Kasada bypass guide: how Kasada works and what a solver returns.
- Akamai Bot Manager bypass guide: _abck, bm_sz and sensor_data explained.