Dhan API: DH-905 "Invalid IP"
Dhan returns DH-905 Invalid IP when an order reaches it from an address that isn't your registered primary or secondary static IP. The other common cause is an access token generated before you added the IP. Both are quick to check.
Check what Dhan sees
Dhan shows the address it detects. In Dhan Web open Profile, Get Trading & Data API, then Sandbox (top right), IP Setup, Get Static IP. You'll see your primary IP, secondary IP and the Detected IP. The detected IP must match one of the other two.
The fixes
- Regenerate your access token. Dhan's support page says to re-generate the token once if the IP was added after the token was created.
- Send orders from the registered address. If the detected IP is different, your orders are leaving from another connection. Route your Dhan client through the registered IP; the code is on static IP for the Dhan API.
- Match IPv4 or IPv6. Dhan's order host is reachable over both. If you registered an IPv4 but your traffic leaves over IPv6 (or the reverse), register the address your connection actually uses:
curl -x http://USER:PASS@HOST:PORT https://ifconfig.co - Update the IP if it changed. Home broadband IPs change after router restarts. Dhan lets you change an IP only once in 7 days, so a home IP that keeps changing will keep causing DH-905. A dedicated static IP stops that.
What isn't checked
Only order placement APIs need the registered IP: orders, Super Orders and Forever Orders. Fetching order or trade details works from anywhere. If those calls succeed and orders fail with DH-905, it's the IP, not your token or code.
FAQs
I added my IP but still get DH-905. Why?
Most often the token was generated before the IP was added. Regenerate it. If it persists, compare the Detected IP in Dhan's sandbox with your registered IPs.
Does Dhan accept IPv6?
Yes, Dhan's docs say both IPv4 and IPv6 formats are supported. A dedicated IPv6 at TrueIP is ₹50 a month plus GST.
Sources
- Dhan support: DH-905 Invalid IP
- DhanHQ v2 docs: authentication and static IP
- Dhan support: why I can't modify my IP
Get your dedicated static IP
IPv6 ₹50 a month, IPv4 ₹200 a month, plus GST. Live in minutes, whitelisted once.