Submit a toolSubmit

OpenAI API returns 401 ip_not_authorized. Fix the IP allowlist

HTTP 401 ip_not_authorized means a valid key’s egress IP is off the allowlist. Add the IP or CIDR, confirm the list, wait up to 15 minutes, then retest. Short answer: 5 steps. 1) Confirm the error is ip_not_authorized, not a bad key; 2) Find the public egress IP the API actually sees; 3) Add the IP or CIDR on the allowlist that applies; 4) Enable the right scope, then wait before retrying; 5) Retest from allowed and blocked paths.

Last updated: · This page is the decision checklist; the tools list for “Fix OpenAI API 401 ip_not_authorized” is a separate URL.

The problem: HTTP 401 ip_not_authorized means a valid key’s egress IP is off the allowlist. Add the IP or CIDR, confirm the list, wait up to 15 minutes, then retest.

How do I add the egress IP when OpenAI returns 401 ip_not_authorized?

  1. Confirm the error is ip_not_authorized, not a bad key

    Read the response body. HTTP 401 with `ip_not_authorized` means the source IP failed an active IP allowlist check even if the key is valid. That is different from “Incorrect API key provided” or “Invalid Authentication.” Error codes: https://developers.openai.com/api/docs/guides/error-codes

  2. Find the public egress IP the API actually sees

    Measure the IP from the same path that sends the request (production host, CI runner, NAT gateway, VPN, or proxy)—not only your laptop. Cloud and container egress often differs from local Wi‑Fi. OpenAI evaluates the public source IP that reaches api.openai.com. IP allowlist guide: https://developers.openai.com/api/docs/guides/ip-allowlist

  3. Add the IP or CIDR on the allowlist that applies

    In platform Settings → Security → IP allowlist, add an address (for example `203.0.113.10`) or CIDR (`203.0.113.0/24`). You can list up to 50 entries. Use the Check tool to verify the address is covered. Project-level allowlists override organization allowlists and do not merge—if the project has its own active list, only that list counts.

  4. Enable the right scope, then wait before retrying

    Enable the allowlist for the specific project tied to the key, or for the whole organization if that is intentional. Organization enablement affects every project without its own active list, including staging and CI. Changes can take up to 15 minutes to apply—retrying immediately often still fails.

  5. Retest from allowed and blocked paths

    From an allowed path: `curl https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"` should authenticate normally. From an IP not on the active list, you should still see 401 `ip_not_authorized`. If production still fails, re-check NAT/VPN egress and which org/project the key belongs to. IP allowlisting is not a substitute for key rotation, and Private Link is not compatible with IP allowlist controls.

Which tools are best to fix OpenAI API 401 ip_not_authorized?

IP allowlist guide

Configure project vs organization allowlists, Check tool, and troubleshooting for blocked egress.

Error codes

Distinguishes ip_not_authorized from bad-key and other 401s.

Platform IP allowlist settings

Add IPs/CIDRs and enable allowlisting for a project or the organization.

RBAC / permissions

Org owners need IP allowlist Read/Write to change the list.

All tools for “Fix OpenAI API 401 ip_not_authorized” →

Related fixes

See also AI tools launched today on the daily board.