Shadowrocket REJECT Rules: Syntax, Matching, and Limits

Learn how Shadowrocket REJECT rules block requests by domain or IP, with examples, matching order, and limits for content served from the same domain.

At a glance

REJECT is an action applied when a request matches a rule; it is not a page-element filter. This guide is for Shadowrocket users who are ready to edit Config: first distinguish match conditions from actions, then test domains, IPs, and rule order, and finally understand the limits of same-domain content, caching, and shared IPs. Back up your Config before making changes, and add one rule at a time.

1. REJECT blocks requests, not individual parts of a page

In rule-based routing, DOMAIN-SUFFIX, DOMAIN, and IP-CIDR describe which requests match. The final REJECT specifies what happens when a request matches. For example, DOMAIN,ads.example.com,REJECT rejects requests matching that domain; it does not download a webpage and then search for ad images.

Request sent Tunnel intercepts request Rule matching Request rejected App responds

For this process to work, the request must pass through Shadowrocket, with rule-based routing enabled. The steps below use the iPhone / iPad interface: on Home, set Global Routing to Config, then open Config and confirm the active configuration. Proxy and Direct in Global Routing are not suitable for testing the Config rules in this guide. If you use Scene, also check which routing settings the active scene applies.

After a request matches REJECT, the app may show a loading error, a blank placeholder, or a retry prompt—or simply hide the relevant module. These are responses to a failed request; REJECT does not alter page layout. Rejecting a request also does not delete a remote file or affect other devices.

First, check whether the target can be identified on its own

If the content uses a dedicated domain, start with an exact DOMAIN rule. If it shares a domain with sign-in, page content, or video, don't broaden the block. Check the same-domain limitations below first.

2. Writing DOMAIN, DOMAIN-SUFFIX, and IP-CIDR rules

The domains and IPs below are documentation examples, not a blocklist. Add targets to your own Config only after verifying them in request records; don't treat the example addresses as ready-made tests. When editing an existing file, add rules inside the existing [Rule] section. Don't create duplicate sections with the same name.

[Rule]
DOMAIN,ads.example.com,REJECT
DOMAIN-SUFFIX,metrics.example.org,REJECT
IP-CIDR,192.0.2.10/32,REJECT,no-resolve
FINAL,PROXY

Domain matching

DOMAIN
ads.example.com,REJECT
Match scope
Exact match for ads.example.com
DOMAIN-SUFFIX
metrics.example.org,REJECT
Match scope
metrics.example.org and its subdomains

Enter a domain as the rule parameter—without https://, a port, or a URL path.

IP matching

IP-CIDR
192.0.2.10/32,REJECT,no-resolve
/32
Matches exactly one IPv4 address
no-resolve
Does not trigger an extra DNS lookup to match this IP rule
When to use it
Use when the actual destination IP is confirmed and you accept the scope of blocking that address

192.0.2.10 is a documentation example address, not a recommended target.

DOMAIN-SUFFIX,example.com,REJECT matches example.com and subdomains such as api.example.com, but not notexample.com just because its name contains a similar string. It also can't target a path such as /ads/banner.jpg. Adding a full URL to the domain field does not turn a domain rule into a path rule.

no-resolve does not disable DNS globally or mean “never resolve this domain.” It only prevents this IP rule from triggering an additional lookup for matching purposes. If a target is matched by domain and no destination IP is available, don't expect this rule to resolve the domain and match it. To control traffic by domain, specify the domain condition directly.

3. Rule order: specific exceptions first, broad rules and FINAL last

Regular rules are checked from top to bottom, and the action for the first match is applied. REJECT does not automatically take priority over DIRECT or PROXY. If a broad allow rule covering the target comes first, a later reject rule may never run—even when its syntax is correct.

[Rule]
DOMAIN,account.example.com,DIRECT
DOMAIN-SUFFIX,example.com,REJECT
GEOIP,CN,DIRECT
FINAL,PROXY

This example demonstrates rule order; it does not mean you should change your final action to PROXY. If your Config already uses policy groups or another fallback, preserve its intended behavior and insert only the verified test rule in the right place. In particular, don't set an entire parent domain to REJECT just to block one subdomain, then troubleshoot sign-in, payment, or resource-loading failures one by one.

  1. In Config, save a copy of the current file and note which configuration is active.
  2. Find the existing [Rule] section and check whether an earlier DOMAIN, DOMAIN-SUFFIX, or IP rule already covers the target.
  3. Add one exact DOMAIN rule first, placing it before any broader rule that could match it. Save and confirm that the configuration is active.
  4. Make a new request to the target. Check the request log for its domain, matching rule, and action. Only then decide whether to expand the rule to cover subdomains.

4. Limits of blocking same-domain content, shared IPs, and encrypted traffic

Suppose the page comes from https://www.example.com/article/1 and a promotional module from https://www.example.com/api/promo. Both requests use the same domain, so DOMAIN and DOMAIN-SUFFIX cannot distinguish them by path. Applying REJECT to www.example.com affects both the page and the module; it won't remove only the promotional content.

2 paths
/article/1 and /api/promo can use the same domain
443
HTTPS commonly uses this port; the port itself can't distinguish page content from promotions
/32
Targets one IPv4 address, not a particular website hosted at that address

Takeaway: don't broaden REJECT when paths share a host

First check the request log for a resource on a separately identifiable domain. If the target and essential features always use the same host, remove the domain-wide rejection rather than extending the rule to a shared IP.

HTTPS encrypts request paths and response content. The domain and IP rules covered here do not read or rewrite page content, and they cannot keep the article text while removing one promotional section from the same response. Even when one response contains several modules, REJECT can only reject the request; it cannot selectively allow or block fields in the response.

IP rules can affect a much wider range of traffic than domain rules. Multiple sites may share a CDN address, and one domain may resolve to different IPs depending on network, location, and time. Blocking an address could disrupt other sites or stop working when the address changes. An IPv4 rule does not automatically cover IPv6 destinations, so continued access after blocking one IP does not by itself mean the rule engine failed.

5. If REJECT doesn't work, check the Config, request, and match result

“The content is still visible” and “the rule didn't match” are two different things. Browser caches, an app's local database, or an existing connection may temporarily preserve old content. To test, first check whether a new request to the target was made, then see which rule it matched, and only then assess what the app displays. Don't change several rules based only on how the page looks.

  1. Check the connection and routing mode: Confirm Shadowrocket is connected, Home → Global Routing is set to Config, and Config has the file you just saved selected.
  2. Trigger a new request: Close the target page or quit the relevant app, then reopen it. If needed, disconnect and reconnect Shadowrocket to avoid reusing a connection established before the change.
  3. Check the actual target: Compare the full domain and destination IP in the request log. Don't assume every resource comes from the same host based only on the page's address bar.
  4. Check rule order: If the log shows DIRECT or PROXY, review earlier broad rules, policy-group settings, and the current routing mode.
  5. Test by rolling back: Temporarily remove the rule you just added and repeat the same steps. Keep the change only if the result is reproducible under the same network and usage conditions.

Why is the ad space still there after adding REJECT?

Check whether the refresh generated a new request and whether that request matched REJECT. If it did and only a blank area remains, the app may have reserved space in its layout; rejecting a request does not remove the page container. If old content is still visible, leave the page and trigger a fresh load before checking again.

Why did sign-in and images stop working after adding one rule?

Remove the new rule first to restore essential features. Check whether you used a DOMAIN-SUFFIX rule for the parent domain or blocked a shared IP. Then use request records to find a separate host and test it with an exact DOMAIN rule. Don't keep adding broader rejection rules.

Why didn't updating Subscribe change the rules?

Updating a node subscription and editing rules in the active Config are separate operations. Go back to Config and check which file is active. If you already have a subscription URL, get it from your service provider; updating a node list does not prove that REJECT rules have loaded.

Does turning on On Demand make REJECT more powerful?

No. Settings → On Demand controls when a connection is requested based on conditions. It does not change the matching scope of DOMAIN-SUFFIX or filter response content. Check the connection status and active Config first, then review the rule itself.

6. Keep a minimal rule set and document impact and rollback steps

Change one condition at a time to distinguish a request being rejected from content simply not appearing on the page. For each rule you intend to keep, record its purpose, the actual domain, the expected action, and how to roll it back. Don't assume a domain can be blocked just because its name contains strings such as ads or track. Names are clues; request records and feature testing are what matter.

REJECT works best for requests that can be clearly identified by their destination domain or address and can be blocked as a whole. When content shares a domain, is embedded in a response, or relies on shared infrastructure, recognizing the limits of matching conditions is more likely to keep your Config usable than expanding the block indefinitely.

Get Shadowrocket and learn the basics

Get Shadowrocket for iPhone / iPad from the App Store for a one-time $2.99 purchase; the developer is Shadow Launch Technology Limited. Check the App Store listing for system requirements. The Mac (Apple Silicon / Intel), Windows, Android, and Linux versions are free. Shadowrocket is closed-source commercial software; the app price does not include service-provider costs. Set up a basic connection before testing REJECT rules one at a time.

Download Shadowrocket