How to Use Your StaticIP.in Static IP with OpenAlgo
OpenAlgo sends every broker order from the machine it runs on. If that machine doesn't have a fixed,
whitelisted IP a home PC, a laptop, a cloud server whose IP can change your broker will reject
the orders. Here's how to send all of OpenAlgo's broker traffic out through your dedicated
StaticIP.in IP: five lines in .env, one small code edit, and a restart.
Why one change covers everything
OpenAlgo has many ways to place an order such as TradingView and ChartInk webhooks, Amibroker, Excel, the
Python strategy host, Flow, the Strategy module, the scalping terminal. But they all end up in the
same place: OpenAlgo's broker plugins, and every one of them talks to the broker through a single
shared HTTP client in utils/httpx_client.py. Send that one client through your static
IP and every order, from every source, leaves from the IP your broker has whitelisted.
Before you start
- An active static IP. Your Host, Port, Userid and Password are in your dashboard. No IP yet? See how to buy one.
- That IP whitelisted with your broker. Add the IP address shown in your dashboard in your broker's API app settings (Zerodha Kite developer console, Dhan, Fyers, Angel One and so on).
-
OpenAlgo installed and working - either directly with
uv, on Ubuntu with the install script, or in Docker. All three are covered below.
Your StaticIP.in Userid and Password are separate from your broker's API key and secret, and separate from OpenAlgo's own API key. Don't mix them up.
Step 1 - Add your proxy details to .env
Open the .env file in your OpenAlgo folder (the same file that holds your
BROKER_API_KEY) and add this block at the end. Replace the values with the ones from
your dashboard.
# StaticIP.in proxy - set to 'true' to send broker orders through your static IP, 'false' to connect directly
PROXY_ENABLE = 'true'
STATICIP_SCHEME = 'http'
STATICIP_IP = 'dc-mum-XXX.staticip.in'
STATICIP_PORT = '443'
STATICIP_USERID = 'your_staticip_userid'
STATICIP_PASSWORD = 'your_staticip_password'
PROXY_ENABLE-'true'turns the proxy on. Anything else (or leaving it out) keeps OpenAlgo connecting directly, exactly as before.STATICIP_SCHEME- leave this as'http', even though the port is 443. It describes how OpenAlgo talks to the proxy; your broker traffic inside it is still fully encrypted HTTPS.STATICIP_IP- the Host from your dashboard, e.g.dc-mum-XXX.staticip.in. Copy the exact value shown; the number depends on which server your IP was issued from. The raw IP address works too.STATICIP_PORT,STATICIP_USERID,STATICIP_PASSWORD- copy these from your dashboard as they are.
.env is already excluded from git in OpenAlgo, so these credentials won't be committed.
Don't paste them into screenshots or support chats.
Step 2 - Add proxy support to utils/httpx_client.py
Open utils/httpx_client.py in your OpenAlgo folder. You'll make two small additions.
Nothing is removed, so the rest of the file stays as your OpenAlgo version has it.
2a. Add this function just above def _create_http_client()
It reads your .env settings and builds the proxy address. If the proxy is turned on but a
value is missing, it stops with a clear error instead of quietly sending orders from an IP your broker
doesn't recognise.
def get_static_ip_proxy() -> str | None:
"""Return the StaticIP.in proxy URL for broker REST/order calls, or None.
Reads PROXY_ENABLE and STATICIP_* from .env. Returns None when the proxy
is disabled, so the client connects directly exactly as before.
Raises:
ValueError: PROXY_ENABLE is true but a required STATICIP_* key is
empty. Failing loudly is deliberate: silently going direct would
send orders from an IP the broker has not whitelisted.
"""
import os
from urllib.parse import quote
def _env(key: str) -> str:
return os.getenv(key, "").strip().strip("'\"")
if _env("PROXY_ENABLE").lower() not in ("true", "1", "yes"):
return None
cfg = {k: _env(k) for k in ("STATICIP_IP", "STATICIP_PORT", "STATICIP_USERID", "STATICIP_PASSWORD")}
missing = [k for k, v in cfg.items() if not v]
if missing:
raise ValueError(f"PROXY_ENABLE is true but these are missing in .env: {', '.join(missing)}")
scheme = _env("STATICIP_SCHEME").lower() or "http"
user = quote(cfg["STATICIP_USERID"], safe="")
pwd = quote(cfg["STATICIP_PASSWORD"], safe="")
return f"{scheme}://{user}:{pwd}@{cfg['STATICIP_IP']}:{cfg['STATICIP_PORT']}"
2b. Use it inside _create_http_client()
Further down in _create_http_client(), find the line client = httpx.Client(.
Add the proxy lookup just above it, and add proxy=proxy, as the first argument:
# StaticIP.in proxy (None = direct, the default)
proxy = get_static_ip_proxy()
if proxy:
# Log host:port only - never the userid/password part of the URL
logger.info(f"Broker REST calls routed via static IP proxy {proxy.rsplit('@', 1)[-1]}")
client = httpx.Client(
proxy=proxy, # None = direct connection
http2=http2_enabled,
# ... leave every other existing argument exactly as it is ...
Keep the indentation the same as the surrounding code (8 spaces, inside the try: block).
Leave the other arguments (http1, timeout, limits,
verify, event_hooks) exactly as they are in your file. Different OpenAlgo
versions set them slightly differently, which is why this guide asks you to add two pieces rather
than replace the whole file.
Step 3 - Restart OpenAlgo
OpenAlgo reads .env and builds its HTTP client only at startup, so restart it the way you normally run it:
# Running locally with uv - stop it (Ctrl+C), then:
uv run app.py
# Ubuntu server installed with install.sh
sudo systemctl restart openalgo
# Docker (run from the folder with docker-compose.yaml)
docker compose restart
Step 4 - Confirm orders are really leaving from your static IP
First, check the OpenAlgo log right after the first broker call (log in to your broker, or open the positions page). You should see:
Broker REST calls routed via static IP proxy dc-mum-XXX.staticip.in:443
Then confirm the outgoing IP directly. This uses OpenAlgo's own client, so it shows exactly which IP your orders will come from. Pick the line that matches how you run OpenAlgo:
# Running locally with uv (from your OpenAlgo folder)
uv run python -c "from dotenv import load_dotenv; load_dotenv(); from utils.httpx_client import get_httpx_client; print('Outgoing IP:', get_httpx_client().get('https://api64.ipify.org', timeout=10).text)"
# Ubuntu server installed with install.sh
cd /var/python/openalgo && sudo -u www-data .venv/bin/python -c "from dotenv import load_dotenv; load_dotenv(); from utils.httpx_client import get_httpx_client; print('Outgoing IP:', get_httpx_client().get('https://api64.ipify.org', timeout=10).text)"
# Docker
docker exec -it openalgo-web python -c "from dotenv import load_dotenv; load_dotenv(); from utils.httpx_client import get_httpx_client; print('Outgoing IP:', get_httpx_client().get('https://api64.ipify.org', timeout=10).text)"
The IP it prints should match the static IP in your dashboard and the one whitelisted with your
broker. If it shows your normal internet IP, the proxy isn't active: check
PROXY_ENABLE and that you restarted. Do this once after every change, before you trust
the setup with a real order.
What goes through the static IP, and what doesn't
- Through your static IP: everything OpenAlgo sends to your broker's REST API - placing, modifying and cancelling orders, the order book, positions, holdings, funds, quotes and historical data. This is the traffic SEBI's static IP rule covers.
- Still direct: the live market-data WebSocket feed and the daily master-contract (symbol list) download. Brokers don't check the IP on these, so leaving them direct is fine and keeps live ticks fast.
- OpenAlgo's other outbound calls that use the same client - Telegram alerts, for example - also go through the proxy. That's harmless.
Turning it off
Set PROXY_ENABLE = 'false' in .env and restart. OpenAlgo goes back to
connecting directly. You can leave the code change in place - with the proxy off, it does nothing.
Updating OpenAlgo later
Because you've edited utils/httpx_client.py, a plain git pull may stop and
say your local changes would be overwritten. Set your edit aside, update, then put it back:
git stash
git pull
git stash pop
If git stash pop reports a conflict in httpx_client.py, take the new upstream
file (git checkout --theirs utils/httpx_client.py) and re-add the two pieces from Step 2.
Your .env settings are untouched by updates. Restart, then run the check in Step 4 again.
Troubleshooting
-
Error says "PROXY_ENABLE is true but these are missing in .env" - one of the
STATICIP_*lines is empty or misspelled. The error lists which one. This is deliberate: OpenAlgo refuses to send orders rather than send them from the wrong IP. - "407 Proxy Authentication Required" - the Userid or Password doesn't match your dashboard. Copy them again; watch for stray spaces.
- Timeouts or "connection refused" - check the Host and Port, and that your IP hasn't expired (see how to renew).
- Broker says the IP isn't registered or whitelisted - the IP whitelisted in your broker's API settings doesn't match the one Step 4 prints. Some brokers take a few minutes to apply a change.
- Nothing about the proxy in the log - OpenAlgo wasn't restarted, or the code edit wasn't saved in the OpenAlgo folder it actually runs from.
Writing your own Python bot instead?
See the generic Python proxy guide and the broker-specific setup guide for Zerodha, Fyers, Angel One, Dhan and Upstox.
Stuck?
Message us or ping +91 94706 69031 on WhatsApp with the error line from your OpenAlgo log (remove your password first) and we'll help you get it working.
Don't have a static IP yet?
SEBI-compliant IPv4/IPv6 from ₹100/month. Whitelist-ready in minutes.