How to Fix the "IP Not Whitelisted" Error on Indian Broker APIs
Getting IP-not-whitelisted or invalid-session errors from Zerodha, Fyers, Dhan or Angel One APIs? Diagnose the cause and fix it permanently with a static IP.
What the error actually means
When a broker API returns "IP not whitelisted", "request origin mismatch" or abruptly invalidates your token, its edge servers compared the source IP of your HTTPS request against the address registered for your API key — and they didn't match. The broker is working as designed; your network is the problem.
Step 1 — Find out what IP the broker is seeing
Run this twice a few hours apart (or after rebooting your router). If the two answers differ, you have a dynamic IP — the root cause.
Step 2 — Understand why your IP keeps changing
- DHCP lease renewal: ISPs rotate consumer IPs periodically by design.
- CGNAT: Jio, Airtel and most Indian ISPs put many customers behind one shared public IP that can change per connection.
- Router/ONT restarts and power cuts force a new lease.
- Mobile hotspots change IP with every tower handoff.
Step 3 — The permanent fix: dedicated static IP
Provision a dedicated Indian static IP, whitelist it once in the broker portal, and route your bot through it via HTTP or SOCKS5 proxy. Your origin address becomes constant regardless of what your ISP does.
Step 4 — Verify and monitor
- Confirm the exit IP through the proxy matches the whitelisted address exactly.
- Add a pre-market sanity check to your bot: fetch the exit IP; refuse to trade if it differs.
- Use your provider's health check (Algo-IP dashboard has one-click IP health tests).
Errors that disappear after this fix
- Zerodha: TokenException / "Invalid session credentials".
- Fyers: invalid_auth or request-origin errors.
- Angel One: AG8001, AB1004 token errors.
- Dhan: 401 unauthorised on previously working keys.