On this page
Confirm the rejection is the IP check
The major Indian brokers now check the source IP of order requests, and only order requests. Zerodha requires a static IP for API order placement from 1 April 2026 and leaves the WebSocket feed, order book, and positions open from any IP. Angel One's SmartAPI announcement limits the check to placing, modifying, and cancelling orders plus the GTT calls. Dhan applies it to the Orders, Super Order, and Forever Order APIs. Upstox ties it to order traffic. Kotak Neo checks the place, modify, and cancel order APIs, and also needs the session created from the IP that sends the orders.
That scope is your first clue. If quotes, positions, and the order book work from the same process and only order placement fails, you are looking at the IP check. An expired token would break the other calls too.
| Broker | Rejection | Reported in |
|---|---|---|
| Zerodha Kite Connect | PermissionException with IP (a.b.c.d) is not allowed to place orders for this app. The brackets hold the address Zerodha saw. | Kite forum |
| Upstox | HTTP 403 on POST /v2/order/place, errorCode UDAPI1154, Access to this API is blocked due to static IP restrictions. | Upstox community |
| Dhan | DH-905 with an invalid IP message | Dhan support |
| Angel One SmartAPI | AG7002, Access denied: Unregistered IP address. Register your IP before retrying. | Tradetron community |
| Kotak Neo | stCode 100008 with errMsg unauthorized from an IP not whitelisted. stCode 1037, session ip doesnt match with reqest ip (Kotak's spelling), when the session came from another IP. | Kotak Neo |
Most of these strings come from developer forums and support pages, not from a published error reference, so match on the code and log the whole response body. Two details matter. Kite's message prints the address Zerodha saw, which is the most useful fact you can get. Dhan's DH-905 is a generic code. The DhanHQ annexure lists it as Input Exception, for missing fields and bad parameter values, so read the message before you blame the IP.
status set to failure and the broker's code and message under remarks. A bot that only catches exceptions never sees the rejection. Log remarks on every order call. Check this against the dhanhq release you run.Find the address the broker actually sees
Your registered IP and your egress IP are two different facts. The first is what you typed into a console. The second is the source address of the connection that reached the broker. The Kite Connect FAQ says the two must match exactly, and the other brokers behave the same way.
Run the checks on the machine that places orders, as the same user, inside the same container. A test from your laptop tells you nothing about a VPS. The ipify endpoints make the address family explicit. api.ipify.org answers over IPv4 only, api6.ipify.org over IPv6 only, and api64.ipify.org over whichever family your system picks.
# Your IPv4 and IPv6 egress, each forced to one family
curl -4 -s https://api.ipify.org; echo
curl -6 -s https://api6.ipify.org || echo "no IPv6 egress"; echo
# The family this host picks when both work
curl -s https://api64.ipify.org; echo
# Which order hosts publish IPv6 (AAAA) records
for h in api.kite.trade api-hft.upstox.com api.dhan.co apiconnect.angelone.in; do
echo "$h A: $(dig +short A "$h" | tr '\n' ' ') AAAA: $(dig +short AAAA "$h" | tr '\n' ' ')"
done
# Through your order proxy, if you use one
curl -s --proxy "$ORDER_PROXY_URL" https://api64.ipify.org; echoIf your host has IPv6 egress and the broker's order host has an AAAA record, assume the order goes out over IPv6. If the broker host has only A records, the order uses IPv4.
Then read the broker's side back. Upstox returns the registered pair and when each was last changed from GET /v2/user/ip. Dhan's GET /v2/ip/getIP returns primaryIP, secondaryIP, and the date each slot can next change. The Sandbox view under IP Setup in Dhan Web adds the Detected IP and an Orders Allowed Status, per Dhan support. Zerodha documents no lookup call, but its rejection names the IP it saw, and Zerodha staff suggested testing with an AMO order. Cancel the AMO before the market opens.
# Upstox: the registered pair and when each was last updated
curl -s https://api.upstox.com/v2/user/ip \
-H "Accept: application/json" \
-H "Authorization: Bearer $UPSTOX_ACCESS_TOKEN"
# Dhan: the registered pair and when each slot can next change
curl -s https://api.dhan.co/v2/ip/getIP \
-H "Accept: application/json" \
-H "access-token: $DHAN_ACCESS_TOKEN"IPv6 is leaving instead of IPv4
This is the usual cause when the IP looks right. Your server has a static IPv4 address, you registered it, and the operating system connects over IPv6 anyway. The default address selection table in glibc, shown in the gai.conf man page, gives IPv4-mapped addresses (::ffff:0:0/96) precedence 10, the lowest in the table. A dual-stack host therefore tries IPv6 first whenever the broker host publishes an AAAA record.
Zerodha's FAQ names this exact case. Requests that go out over IPv6 while only the IPv4 address is whitelisted are rejected. Kite staff added that the choice is not controlled at the KiteConnect library or SDK level. Dhan users reported the same failure, plus a second trap. Dhan stored one user's IPv6 address in its long form, the detected address arrived in compressed form, and the two did not match. Angel One's announcement and Kotak Neo support only IPv4 static IPs for now.
You have two fixes. Register the IPv6 address as well, if your broker accepts it and the address is static. Kite, Upstox, and Dhan say they accept both families. Or make the order client use IPv4 only. The second works at every broker and is easier to reason about.
import socket
import urllib3.util.connection as urllib3_connection
# requests uses urllib3, and urllib3 calls this function on every new
# connection to pick the address family. Returning AF_INET makes
# getaddrinfo() return IPv4 addresses only. Run it before the first request.
urllib3_connection.allowed_gai_family = lambda: socket.AF_INET// npm install undici
import { Agent, fetch } from "undici";
// undici passes connect options through to net.connect() and tls.connect(),
// so family: 4 restricts the DNS lookup to IPv4.
const ipv4Only = new Agent({ connect: { family: 4 } });
const res = await fetch("https://api64.ipify.org", { dispatcher: ipv4Only });
console.log(await res.text()); // an IPv4 address# Give IPv4-mapped addresses the highest precedence for getaddrinfo().
# This changes address order for every program on the host.
echo 'precedence ::ffff:0:0/96 100' | sudo tee -a /etc/gai.conf
# IPv4 addresses should now be listed first
getent ahosts api.kite.trade | head -3The gai.conf change has a catch. The man page notes that a single precedence line replaces the whole default table, so test it on a staging host first. If your orders go through a proxy, none of this matters for the broker. The broker sees the proxy's egress address, whichever family your bot used to reach the proxy. For dual-stack behaviour on AWS and GCP, see IPv6 egress and IPv4-only allowlists.
The outbound IP drifted
A setup that worked for weeks and then failed at 9:15 one morning usually means the egress IP changed. These are the common reasons.
- Home broadband. Most residential connections get a dynamic address that can change after a router restart, and some ISPs put home users behind carrier-grade NAT. See home static IP vs VPS vs proxy for the INR costs of each fix.
- A cloud VM without a reserved address. On AWS, the auto-assigned public IPv4 address is released when the instance is stopped, hibernated, or terminated, and a new one is assigned on start (AWS docs). An Elastic IP stays with you.
- Serverless functions and PaaS containers. They leave from shared address pools that change. See why serverless egress IPs change and algo trading on serverless.
- More egress addresses than slots. A NAT gateway with three addresses, or a platform that publishes a list of outbound IPs, cannot fit in two broker slots. Any new connection can leave from an address you did not register.
- A VPN or network change. If orders go through a VPN, the VPN's exit address is the one that counts.
First make the address stable. Then make the bot prove it before it trades. A startup check costs one request and turns a morning of rejected orders into one clear log line.
import ipaddress
import os
import sys
import requests
# Comma-separated, as registered with the broker: "203.0.113.10,203.0.113.11"
REGISTERED = {
ipaddress.ip_address(s.strip())
for s in os.environ["BROKER_REGISTERED_IPS"].split(",")
if s.strip()
}
# Use exactly the proxy settings the order client uses, or None for direct.
proxy = os.environ.get("ORDER_PROXY_URL")
PROXIES = {"http": proxy, "https": proxy} if proxy else None
def egress_ip() -> ipaddress.IPv4Address | ipaddress.IPv6Address:
res = requests.get("https://api64.ipify.org", proxies=PROXIES, timeout=10)
res.raise_for_status()
return ipaddress.ip_address(res.text.strip())
ip = egress_ip()
if ip not in REGISTERED:
sys.exit(f"egress IP {ip} is not registered with the broker, refusing to trade")
print(f"egress IP {ip} matches a registered address")The guard compares parsed addresses, so a compressed and an expanded IPv6 address count as equal, and stray spaces do not cause a false alarm. Run it at startup and before the first order of each session. If it fails, exit. Do not trade and hope.
One limit applies. Without a proxy, api64.ipify.org shows the family your host picks for ipify, which can differ from the family it picks for the broker. Pair the guard with the IPv4-only client setting above, and the result holds for both.
The right IP in the wrong slot or account
Each broker scopes the registration differently, and a correct address in the wrong place still fails.
| Broker | Where the IPs belong | Change limit | After a change |
|---|---|---|---|
| Zerodha Kite Connect | The developer account profile, shared by every app under it (FAQ) | Once per calendar week | Updates take effect immediately, per the FAQ |
| Upstox | Your user account, whichever OAuth client issued the token (docs) | Once per calendar week, or UDAPI1185 | Existing access tokens are invalidated, so generate a new one |
| Dhan | Your account, as a PRIMARY or SECONDARY ipFlag (docs) | Once every 7 days | Regenerate the access token if you added the IPs after creating it (support) |
| Angel One SmartAPI | The app you create with Add App (Angel One). An IP already on another app is refused | Once per calendar week | Not documented. Ask SmartAPI support which API key to use |
| Kotak Neo | Your Trade API application, primary and secondary (Kotak Neo) | Once every 7 days | Create a new session from the IP that sends the orders |
These patterns cause most of the trouble.
- You changed the IP and kept the old token. On Upstox the old token stops working after the update. On Dhan, a token generated before the IPs were added should be regenerated.
- The right address sits in the secondary slot and a typo sits in the primary. In one Dhan thread, getIP reported
SECONDARY_MATCHwith orders allowed, so a secondary match was enough there. The primary still cannot change for 7 days. - The address is registered on another account. A user on the SmartAPI forum got
Primary Static IP is already associated with another appwhen registering the same IP for a family member's account. Kite lets a spouse, dependent children, and dependent parents share one address through one developer account (Zerodha), and warns that sharing outside the family can suspend the account (FAQ). - Both slots hold the same address. Upstox rejects that with
UDAPI1184(docs). Other brokers may accept it, but you lose the failover the second slot exists for. See why brokers ask for a primary and secondary IP.
Check the address twice before you save. A typo costs you a week.
The proxy is set, but not on the order client
Routing orders through a proxy or fixed-IP gateway adds a new way to fail. The proxy works in your shell, the echo test passes, and orders still arrive from the server's own address. Almost always, the HTTP client that sends the order never saw the proxy settings.
- The variable lives in your shell, not the service. An
export HTTPS_PROXY=...in.bashrcdoes not reach a systemd unit, a cron job, or a Docker container. Set it in the unit'sEnvironment=line, the crontab, or the container's environment. NO_PROXYmatches the broker host. A broad entry such as.com, or a list copied from another project, sends broker traffic direct. See NO_PROXY and per-client agents.- Orders use a different host from data. Upstox's v3 place order call goes to
api-hft.upstox.com(docs), notapi.upstox.com. A per-host proxy rule that names only one of them proxies your quotes and sends orders direct. - The SDK has its own session. Proxy settings on your own
requests.Sessiondo nothing for the SDK's session. And the requests docs warn thatsession.proxiescan be overwritten by environment proxies. Passingproxies=on each request avoids that. - The SDK takes a proxy URL but drops the credentials. The Upstox Python SDK passes
Configuration.proxyto urllib3'sProxyManagerwith no proxy headers (source), and urllib3 does not turnuser:pass@in the URL into aProxy-Authorizationheader. An authenticated proxy then answers 407. Call the order endpoint withrequestsinstead, which does send those credentials.
The safest pattern is to hand the proxy to the order client explicitly. The Kite and SmartAPI Python SDKs accept a proxies dict and pass it to every request (pykiteconnect, smartapi-python). dhanhq 2.3.0 has no proxy option, but it sends through a plain requests.Session, so it honours HTTPS_PROXY.
# pip install kiteconnect
import os
from kiteconnect import KiteConnect
proxy = os.environ["ORDER_PROXY_URL"]
kite = KiteConnect(
api_key=os.environ["KITE_API_KEY"],
access_token=os.environ["KITE_ACCESS_TOKEN"],
proxies={"http": proxy, "https": proxy}, # used on every request
)
order_id = kite.place_order(
variety=kite.VARIETY_REGULAR,
exchange=kite.EXCHANGE_NSE,
tradingsymbol="INFY",
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=1,
product=kite.PRODUCT_CNC,
order_type=kite.ORDER_TYPE_LIMIT,
price=1400.0,
)
print(order_id)# pip install smartapi-python pyotp
import os
import pyotp
from SmartApi import SmartConnect
proxy = os.environ["ORDER_PROXY_URL"]
smart = SmartConnect(
api_key=os.environ["SMARTAPI_KEY"],
proxies={"http": proxy, "https": proxy},
)
# Login and every later call, placeOrder included, use the proxy.
smart.generateSession(
os.environ["SMARTAPI_CLIENT_CODE"],
os.environ["SMARTAPI_PIN"],
pyotp.TOTP(os.environ["SMARTAPI_TOTP_SECRET"]).now(),
)# dhanhq documents no proxy option, but its requests.Session reads the
# standard variables. Set this where the bot runs, not only in your shell.
export HTTPS_PROXY="$ORDER_PROXY_URL"
python bot.pyThe SmartAPI Python SDK also sends X-ClientPublicIP and X-ClientLocalIP headers. In the current source those values are hard-coded. They do not change the address your connection comes from, so editing them fixes nothing.
If the proxy itself refuses the call, with a 407, a 403 from the proxy, or a 502 on CONNECT, that is a different failure. See proxy error codes explained.
A checklist before you open a ticket
- 1Capture the full errorLog the HTTP status, the broker's error code, the message, and the time in IST.
- 2Print the egress IP from the order processCheck IPv4 and IPv6 separately, and through the proxy if the order client uses one.
- 3Read the registered IPs back from the brokerUse Upstox
GET /v2/user/ip, DhangetIPor its Sandbox view, or the profile page of the Kite developer console. - 4Compare parsed addressesDo not compare strings. IPv6 compression and stray spaces both cause false mismatches.
- 5Regenerate the token after any IP changeUpstox invalidates the old token. Dhan asks for a new one if you added the IPs after creating it. Kotak Neo needs a new session.
- 6Prove the order client uses the proxyRun the egress check with the same proxies dict or environment the SDK uses.
- 7Send the broker four factsThe error body, the egress IP you measured, the registered IPs, and the time of the rejection.
Doing this with Fixedmark
Fixedmark is one way to get the stable IPv4 egress this guide keeps asking for. It is in early access. The planned India Trader plan gives you a dedicated pair of IPv4 addresses in Mumbai. See planned India pricing. You register the two addresses as primary and secondary and send order calls through one proxy URL. The broker sees one of your two addresses wherever the bot runs. Each new connection can leave from either one, so register both. Fixedmark egress is IPv4, so the IPv6 trap above does not apply to proxied calls.
Two features map onto the checklist. Verify egress IP is the echo test, run through the proxy. Connection logs record the destination, SNI, egress IP, and result of each connection, so you can see whether an order call reached the proxy at all and which address it left from. If you lock a token to its hosts with a destination allowlist, name every order host, such as api-hft.upstox.com:443 for Upstox. A missing host shows up in the logs as denied_by_policy.
Use a dedicated pair. The trial and Starter plans share their pair with other customers, which does not fit the family-only sharing rule. The broker guides cover each console step by step for Zerodha, Upstox, Dhan, Angel One, and Kotak Neo. Kotak Neo needs the session created from the IP that sends the orders, so ask Fixedmark support before you rely on the pair with Kotak Neo. Confirm with your broker that it accepts a cloud IP before you depend on one.
Sources
Checked November 2026. Confirm current details on the vendor's site before you decide. Prices and limits change.
- Zerodha support: Kite Connect API FAQs
- Zerodha support: static IP for Kite Connect
- Kite forum: place_order rejected, IP not allowed for this app
- Kite forum: preparing for SEBI's retail algo rules
- Upstox community: error UDAPI1154 while placing orders
- Upstox docs: Update Static IPs
- Upstox docs: Get Static IPs
- Upstox docs: Place Order V3
- Upstox Python SDK: rest.py proxy handling
- Dhan support: orders rejected with DH-905 invalid IP
- DhanHQ docs: authentication and static IP
- DhanHQ docs: annexure and error codes
- MadeForTrade: IP invalid though secondary IP is valid
- PyPI: dhanhq
- Tradetron community: Angel One static IP and error AG7002
- SmartAPI forum: updates in compliance with SEBI guidelines
- Angel One: SmartAPI access changes from April 1, 2026
- smartapi-python: smartConnect.py
- Kotak Neo: static IP details for the Trade API
- pykiteconnect: connect.py
- AWS: Amazon EC2 instance IP addressing
- man7.org: gai.conf(5)
- Requests: advanced usage, proxies
- ipify: IP address API

