Skip to content
Fixedmark

Algo trading · 12 min read

Updated

Fixing IP Not Whitelisted Errors on Broker APIs

The broker saw your order arrive from an address that is not in your registered slots. Print the IP your order client actually leaves from, IPv4 and IPv6 separately, and compare it with what the broker has on file. Then fix the side that is wrong. Force IPv4, pin the egress IP, put it in the right slot and regenerate the token, or give the proxy to the order client itself.

On this page

Confirm the rejection is the IP check

This guide is general technical information, not legal or investment advice. Confirm your broker's current rules before you register or change an IP.

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.

What an IP rejection looks like at five brokers
BrokerRejectionReported in
Zerodha Kite ConnectPermissionException with IP (a.b.c.d) is not allowed to place orders for this app. The brackets hold the address Zerodha saw.Kite forum
UpstoxHTTP 403 on POST /v2/order/place, errorCode UDAPI1154, Access to this API is blocked due to static IP restrictions.Upstox community
DhanDH-905 with an invalid IP messageDhan support
Angel One SmartAPIAG7002, Access denied: Unregistered IP address. Register your IP before retrying.Tradetron community
Kotak NeostCode 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.

The dhanhq 2.3.0 Python SDK does not raise on an HTTP error. It returns a dict with 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.

Terminal
# 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; echo

If 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.

Terminal
# 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

The 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.

egress_guard.py
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.

Where each broker keeps the IPs, and what to do after a change
BrokerWhere the IPs belongChange limitAfter a change
Zerodha Kite ConnectThe developer account profile, shared by every app under it (FAQ)Once per calendar weekUpdates take effect immediately, per the FAQ
UpstoxYour user account, whichever OAuth client issued the token (docs)Once per calendar week, or UDAPI1185Existing access tokens are invalidated, so generate a new one
DhanYour account, as a PRIMARY or SECONDARY ipFlag (docs)Once every 7 daysRegenerate the access token if you added the IPs after creating it (support)
Angel One SmartAPIThe app you create with Add App (Angel One). An IP already on another app is refusedOnce per calendar weekNot documented. Ask SmartAPI support which API key to use
Kotak NeoYour Trade API application, primary and secondary (Kotak Neo)Once every 7 daysCreate 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_MATCH with 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 app when 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 .bashrc does not reach a systemd unit, a cron job, or a Docker container. Set it in the unit's Environment= line, the crontab, or the container's environment.
  • NO_PROXY matches 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), not api.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.Session do nothing for the SDK's session. And the requests docs warn that session.proxies can be overwritten by environment proxies. Passing proxies= on each request avoids that.
  • The SDK takes a proxy URL but drops the credentials. The Upstox Python SDK passes Configuration.proxy to urllib3's ProxyManager with no proxy headers (source), and urllib3 does not turn user:pass@ in the URL into a Proxy-Authorization header. An authenticated proxy then answers 407. Call the order endpoint with requests instead, 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)

The 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

  1. 1
    Capture the full errorLog the HTTP status, the broker's error code, the message, and the time in IST.
  2. 2
    Print the egress IP from the order processCheck IPv4 and IPv6 separately, and through the proxy if the order client uses one.
  3. 3
    Read the registered IPs back from the brokerUse Upstox GET /v2/user/ip, Dhan getIP or its Sandbox view, or the profile page of the Kite developer console.
  4. 4
    Compare parsed addressesDo not compare strings. IPv6 compression and stray spaces both cause false mismatches.
  5. 5
    Regenerate 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.
  6. 6
    Prove the order client uses the proxyRun the egress check with the same proxies dict or environment the SDK uses.
  7. 7
    Send 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.

Blog

Frequently asked questions

Why do quotes work but orders get rejected for my IP?

Brokers check the source IP on order calls. Zerodha, Angel One, and Dhan document that market data and order or trade lookups work from any IP, and Upstox ties the check to order placement. A working quote call proves your token is fine, not that your IP is registered.

Can I register an IPv6 address instead of IPv4?

Kite Connect, Upstox, and Dhan say they accept both families. Angel One SmartAPI and Kotak Neo support only IPv4 static IPs for now. An IPv6 address helps only if it is static, and the broker must store it in a form that matches what it detects.

I registered a typo and cannot change it for a week. What can I do?

If the secondary slot is empty, put the correct address there. Dhan tracks a separate modify date per slot, and a secondary match allows orders. On other brokers, ask support whether filling the second slot counts as your weekly change.

Will a VPN fix IP not whitelisted errors?

Only if its exit address is static and used by you or your immediate family alone. Commercial VPN exits are shared by many users, and Zerodha warns that sharing an IP outside the family can lead to suspension of the account.

How soon after updating the IP can I place orders?

Zerodha says updates take effect immediately. Upstox invalidates your access tokens on update, so generate a new one first. Dhan asks you to regenerate the token if you added the IPs after creating it.

Make it fixed.

Fixedmark is in early access. Join the list to get dedicated static IPs when your region opens.