The rule that’s breaking Indian algo bots — and what you must do before markets open
April 1, 2026. SEBI’s static IP mandate went live.
If you’re running an algo trading bot from home, your orders are getting rejected. Dhan, Zerodha, and Upstox now enforce strict IP whitelisting. Dynamic IPs are blocked.
I found out the hard way. Here’s everything you need to stay compliant — without paying ₹10,000/month for a “trading VPS.”
What the rule actually says
SEBI’s circular dated March 2025 mandated that all broker API trading must originate from a static, whitelisted IP address. The intent: traceability. If an algo order goes rogue, regulators should be able to trace it back to a specific machine.
Effective date: April 1, 2026
Enforcement: Strict
Penalty for non-compliance: API access revoked, trading account frozen
Broker-wise breakdown
| Broker | Enforcement | Max IPs Whitelisted | Static IP Cost |
|---|---|---|---|
| Dhan | Strict | 5 | ₹200-500/month |
| Zerodha | Moderate | 3 | ₹300-600/month |
| Upstox | Moderate | 5 | ₹200-500/month |
| Angel One | Strict | 3 | ₹200-500/month |
Dhan is the strictest. They lock your IP for 7 days once set. Change it, and you’re blocked.
How to check if your IP is static
Mac (Terminal):
# Check public IP
curl https://api.ipify.org
# Check if it changes over time
for i in {1..5}; do sleep 10; curl -s https://api.ipify.org; done
Windows CMD:
curl https://api.ipify.org
:: Check over time
for /l %i in (1,1,5) do @timeout /t 10 >nul && curl -s https://api.ipify.org
Linux / Termux:
curl https://api.ipify.org
watch -n 10 curl -s https://api.ipify.org
If the IP changes between checks, you’re on dynamic.
Option 1: ISP static IP (Recommended)
Airtel Xstream Fiber
Process:
- Call Airtel support: 1501 or 1800-103-4444
- Say: “I need static IP for algo trading, SEBI compliance”
- They’ll offer business broadband: ₹300-600/month add-on
- Installation: 2-3 days
Mac/Windows/Linux test after setup:
# Should show same IP always
curl https://api.ipify.org
Whitelist in Dhan:
- Log in to https://api.dhan.co
- Go to API Settings → IP Whitelist
- Add your static IP
- Save — lock for 7 days
JioFiber
Process:
- Call Jio support: 198 or 700
- Say: “Static IP for trading compliance”
- They may push business plan: ₹500-800/month
- Residential static: ₹200-500/month (inconsistent)
Note: Jio’s static IP is CGNAT in some areas. Verify:
# Check if truly static public IP
curl https://ifconfig.me
# Should NOT be 100.x.x.x or 10.x.x.x
Option 2: VPS proxy (Cheapest)
If ISP won’t give static IP:
Hetzner Cloud (€3/month)
Mac / Linux / Windows CMD:
# Create server at https://hetzner.cloud/ref/g9Pj
# Select CX11: 1 vCPU, 1GB RAM, 20GB SSD, €3/month
# SSH into VPS
ssh root@YOUR_VPS_IP
# Install squid proxy
apt update && apt install squid -y
# Configure auth
apt install apache2-utils -y
htpasswd -c /etc/squid/passwd your_username
# Edit squid config
nano /etc/squid/squid.conf
squid.conf snippet:
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
http_port 3128
Restart squid:
systemctl restart squid
Configure your backend:
# Mac/Linux/Termux
export HTTP_PROXY=http://your_username:your_password@VPS_IP:3128
export HTTPS_PROXY=http://your_username:your_password@VPS_IP:3128
# Windows CMD
set HTTP_PROXY=http://your_username:your_password@VPS_IP:3128
set HTTPS_PROXY=http://your_username:your_password@VPS_IP:3128
Whitelist VPS IP in Dhan. Done.
Option 3: Cloudflare Tunnel (Free, risky)
As detailed in my Dhan API Static IP Fix article, Cloudflare Tunnel can work but has limitations:
- Egress IP can change on tunnel restart
- Dhan might block entire Cloudflare range
- No SLA for free tier
Use only as temporary solution.
Option 4: Dhan MCP (Free, no code)
Dhan’s Model Context Proxy (MCP) handles IP whitelisting internally. You don’t manage IPs at all.
Setup:
- Enable MCP in Dhan developer portal
- Connect via Claude Desktop or Cursor
- Trade using natural language
Limitation: MCP is for manual trading, not automated bots. Your XGBoost model can’t call MCP directly.
Compliance checklist
Before you go live:
- [ ] IP is static (test for 24 hours)
- [ ] IP whitelisted in Dhan (max 5)
- [ ] Dhan token regenerated after IP change
- [ ] Backend configured with new token
- [ ] Auto-restart script tested
- [ ] Paper trading for 1 week
- [ ] Error handling for IP mismatch
- [ ] Logging all API responses
Weekly maintenance:
# Check IP hasn't changed
curl -s https://api.ipify.org >> ~/ip_log.txt
diff ~/ip_log.txt ~/last_ip.txt || echo "IP changed! Update Dhan."
Common errors and fixes
Error 100008: Unauthorized
{"stCode": 100008, "errMsg": "unauthorized"}
Cause: IP not whitelisted or token invalid
Fix: Check IP, regenerate token
Error 1037: Session IP mismatch
{"stCode": 1037, "errMsg": "session ip doesnt match with request ip"}
Cause: IP changed after session started
Fix: Wait 7 days or contact Dhan support
Error 905: Missing required fields
{"errorType": "Input_Exception", "errorCode": "DH-905"}
Cause: Token format wrong or expired
Fix: Regenerate token in Dhan portal
The cost comparison
| Solution | Monthly Cost | Setup Time | Reliability |
|---|---|---|---|
| ISP Static IP | ₹200-600 | 2-3 days | 99.9% |
| VPS Proxy | ₹200-300 | 1-2 hours | 99.5% |
| Cloudflare Tunnel | Free | 30 mins | 80% |
| Dhan MCP | Free | 10 mins | 100% (manual only) |
My current setup
I use a hybrid approach:
- Primary: Cloudflare Tunnel (free, mostly stable)
- Backup: ISP static IP (₹300/month, permanent)
- Alert: Auto-detect script logs IP changes
- Manual update: Weekly 1-minute check
Zero order rejections in 6 months.
TL;DR
- Test your IP today — is it dynamic?
- Call ISP — request static IP for trading
- Whitelist in Dhan — add IP, wait 7-day lock
- Monitor weekly — auto-detect script saves logs
- Have backup — VPS or tunnel for redundancy
Compliance isn’t optional. Do this before your next trading session.
Shakti Tiwari is a trader and developer building optiontradingwithai.in. He co-directs CodeVisser and authored books on trading psychology. Find him on Dev.to as @shaktitiwari715-ai.
Top comments (0)