Static IP for the Dhan API
Since 1 April 2026, Dhan accepts API orders only from a static IP registered on your account. You can register a primary and a secondary IP, in IPv4 or IPv6, and change each no more than once in 7 days. Only order placement is checked; data calls work from anywhere.
What Dhan checks
From Dhan's API docs, support pages and staff posts on MadeForTrade:
- Order APIs only. Orders, Super Orders and Forever Orders need the registered IP. Fetching order or trade details doesn't.
- Two addresses. A primary and a secondary IP. Orders from either are accepted.
- 7-day lock. Once set, an IP can't be changed for 7 days.
- IPv4 or IPv6. Dhan's docs say both formats are supported.
- Dhan Cloud is exempt. Strategies deployed on Dhan Cloud don't need your own static IP.
On sharing, Dhan's docs say each individual needs a unique static IP. A Dhan staff reply on MadeForTrade (6 November 2026) adds that parents, spouse and children can share one, linking up to four other accounts, through an offline request to apihelp@dhan.co.
How to register your IP with Dhan
- Get a dedicated IP with its proxy details: host, port, username and password.
- Check the exact exit address:
curl -x http://USER:PASS@HOST:PORT https://ifconfig.co - On web.dhan.co go to My Profile, Get Trading & Data APIs, Add Static IP, and enter it as the primary IP.
- Generate your access token after adding the IP. Dhan says to regenerate it once if the IP was added later.
Dhan also has APIs for this (setIP, modifyIP, getIP), which the Python SDK exposes on DhanLogin.
Send Dhan orders through the fixed IP
The official dhanhq client has no proxy argument, but it uses requests, which reads the standard proxy variables:
import os
PROXY = os.environ["PROXY_URL"] # http://USER:PASS@HOST:PORT
for v in ("HTTPS_PROXY", "HTTP_PROXY"):
os.environ[v] = PROXY # set before importing dhanhq
from dhanhq import DhanContext, DhanLogin, dhanhq
login = DhanLogin(os.environ["DHAN_CLIENT_ID"])
token = login.generate_token(os.environ["DHAN_PIN"], os.environ["DHAN_TOTP"])["accessToken"]
dhan = dhanhq(DhanContext(os.environ["DHAN_CLIENT_ID"], token))
The full Dhan proxy guide on GitHub covers WebSockets, IP checks and troubleshooting.
Check what Dhan sees
In Dhan Web, open Profile, Get Trading & Data API, then Sandbox, IP Setup, Get Static IP. It shows your registered IPs and the Detected IP. They must match.
Common Dhan errors
- DH-905 Invalid IP. The order came from an unregistered address, or the token was generated before the IP was added. Check the detected IP and regenerate the token.
- "IP address is already in use". That IP is registered to another Dhan user. You need an IP that only you use.
- Registered IPv4, proxy leaves over IPv6. Dhan's order host is reachable over both, so register the address your proxy actually uses.
- Can't change the IP. You changed it within the last 7 days.
More on the most common one: fixing DH-905 Invalid IP.
Dhan static IP: FAQs
Does Dhan accept IPv6 for API whitelisting?
Yes. Dhan's API docs say both IPv4 and IPv6 formats are supported, so a dedicated IPv6 at ₹50 a month plus GST works.
Do I need a static IP for Dhan Cloud?
No. Dhan says Dhan Cloud deployments aren't subject to the static IP requirement for external API orders.
How often can I change my Dhan static IP?
Once every 7 days.
Can my family use my IP on Dhan?
A Dhan staff reply says parents, spouse and children can share one IP, up to four linked accounts, through an offline request to apihelp@dhan.co. Dhan's docs otherwise say each individual needs a unique IP, so confirm with Dhan.
Sources
- DhanHQ v2 docs: authentication and static IP
- Dhan support: how to add a static IP
- Dhan support: DH-905 Invalid IP
- Dhan support: static IP and Dhan Cloud
- MadeForTrade: static IP already in use, family linking
- DhanHQ-py client
Get your dedicated static IP
IPv6 ₹50 a month, IPv4 ₹200 a month, plus GST. Live in minutes, whitelisted once.