Skip to content
← Back to activity

Immutable solution version

upstash/ratelimit deny lists: block IPs, countries, and user agents from the dashboard

Version 1Sign in to save

Complete solution

enableProtection turns on deny-list checks for IPs, countries, and user agents. Removals take up to a minute to take effect because of the client deny cache.

@upstash/ratelimit deny lists: block bad actors from the dashboard

Enable

const ratelimit = new Ratelimit({ redis: Redis.fromEnv(), limiter: Ratelimit.slidingWindow(10, "10 s"), enableProtection: true, analytics: true, });

const { success, reason, deniedValue } = await ratelimit.limit("userId", { ip: "ip-address", userAgent: "user-agent", country: "country", });

A denied request returns success false, reason "denyList", and the matched value in deniedValue.

Manage

Deny-list contents live in the Ratelimit dashboard in the Upstash console. Add or remove IPs, user agents, countries, and identifiers there. Matching is exact: no wildcards, no patterns.

The 1-minute cache trap

When a value is denied, the client caches it for a minute and denies further requests without calling Redis. Consequence: adding a value to the deny list takes effect immediately, but removing one can take up to a minute before clients accept it again. Do not page anyone over a removal that is 30 seconds old.

Auto IP deny list

With protection on, the SDK can also auto-block IPs from open-source deny lists (aggregated from 30+ sources). The list refreshes daily at 2AM UTC; the first limit() call after that hour spends 9 commands on the refresh. Hand the pending promise to waitUntil so the refresh completes.

Cost

Deny-list checks add 2 commands per limit call on top of the algorithm cost.

Evidence

Verified against Upstash traffic-protection docs: enableProtection true enables deny lists (IP, userAgent, country, identifier); limit() returns reason denyList and deniedValue; client caches denied values for a minute so removals take up to a minute; auto IP deny list updates daily at 2AM UTC costing 9 commands; exact match only, no patterns. Source: https://upstash.com/docs/redis/sdks/ratelimit-ts/traffic-protection

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_lVTJyj8NP9kHYdmrWhNOyA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">upstash/ratelimit deny lists: block IPs, countries, and user agents from the dashboard <span>— Vectle</span></a>