For readers with an active configuration who want to block specific network requests. Start with a target you can match on its own, then compare behavior before and after enabling one precise rule. If the content shares a domain with essential features, a domain- or IP-based REJECT rule can’t separate them.
What REJECT Can Block
REJECT is an action applied after a rule matches—not a classifier for ads or tracking. For connections handled by Shadowrocket and evaluated against rules, keywords such as DOMAIN, DOMAIN-SUFFIX, and IP-CIDR identify the target. If a matching rule specifies REJECT, the connection is blocked instead of being routed through DIRECT or PROXY.
Test the hostname first, then widen the scope
If the request you want to block uses a dedicated hostname, start with a single DOMAIN test. Confirm that essential features such as sign-in and image loading don’t rely on that host before considering whether to include its subdomains.
A dedicated analytics host, a separate asset host, or a specific IPv4 address that should not be accessed can each be a test target. Whether a target can be blocked on its own depends on whether it has a distinct domain or address—not whether it appears on the page as a banner, video, or regular image. Even if a hostname contains metrics, verify its purpose before blocking it based on its name alone.
Add a Rule and Verify the Match
The steps below use the iPhone / iPad interface. Example domains and IP addresses illustrate rule syntax only; for testing, use a target you control and have confirmed is reachable. Save a copy of your original configuration first, and change one condition at a time so you can identify and undo the effect.
- On
Home, confirm that the connection is on and setGlobal RoutingtoConfig. Also check on theConfigpage that the configuration you intend to edit is active, so you don’t modify a different file by mistake. - Before adding a rule, visit the test target in the same app and confirm the request succeeds. Add one precise rule to the configuration’s
[Rule]section, placing it before any broader rule that could match first. Keep the existingFINALrule at the end. After saving, confirm that the updated configuration is in use. - Retry the connection to the same target and check the request log for the destination and action. If the browser reuses an existing connection or displays cached content, end the session and trigger the request in a new one. Don’t judge whether the rule matched solely by whether the page opens or shows a loading error.
- Remove or disable the test rule, then repeat the same steps. If the request works before the rule, the log shows
REJECTafter you add it, and the request works again when you restore the original configuration, that’s stronger evidence than a single failed load. Keep the network and all other rules unchanged during each test.
Match by domain
- Exact rule
DOMAIN,metrics.example.com,REJECT- Compare the target
img.metrics.example.comdoesn’t match this exact rule- Widen the scope
DOMAIN-SUFFIX,metrics.example.com,REJECT
Test each form separately. When checking subdomains, rule out interference from other rules.
Match by IPv4 address
- Single-address rule
IP-CIDR,192.0.2.10/32,REJECT- Match boundary
192.0.2.11is outside this range- Port boundary
- This rule doesn’t specify a port, so it can’t target TCP 443 alone
192.0.2.10 is a documentation example address, not a test of real-world reachability.
Rule Order and the FINAL Fallback
The flow above shows what happens when REJECT matches. In Config mode, rules are checked from top to bottom and evaluation stops at the first match; Shadowrocket doesn’t continue looking for a more specific condition. Put the exact rule for metrics.example.com before a broader rule for all of example.com so the exception can match first.
[Rule]
DOMAIN,metrics.example.com,REJECT
DOMAIN-SUFFIX,example.com,DIRECT
FINAL,PROXY
In this example, metrics.example.com matches the first rule and is blocked, while www.example.com matches the second and connects directly. Only requests that match neither rule use FINAL,PROXY. If you swap the first two rules, the exact condition in the second rule never gets a chance to handle metrics.example.com, because the earlier suffix rule has already matched it.
Limits of Domain and IP Blocking
Rules can only act on information available when a match is evaluated. Different URLs can use the same hostname, and one IP address can host multiple sites. The broader the condition, the greater the chance of blocking unrelated requests. The table below covers common cases.
| Request scenario | Can a domain or IP rule distinguish it? | What to check |
|---|---|---|
| Analytics and sign-in use different hostnames | They can be handled separately by hostname, as recognized by Shadowrocket. | After blocking the analytics target, check that sign-in and session refresh still work. |
/ads and /account on the same HTTPS host | A domain or IP rule can’t block just one of these paths. | Don’t put a path in DOMAIN; these rules don’t match HTTPS paths. |
| Multiple domains share a CDN address | Blocking the shared IP can’t distinguish between sites hosted at that address. | If the target domain can be identified, match the hostname instead of widening the IP range to catch more traffic. |
| Embedded page content or local cache | Content already delivered with the main response, or stored locally without a new request, won’t be removed by blocking a connection. | Check whether the content triggers a separate request. An empty placeholder doesn’t mean the rule failed to match. |
If an app connects directly to an IP and Shadowrocket has no associated hostname when evaluating the connection, a domain rule may not match. Conversely, an IPv4 IP-CIDR rule doesn’t cover IPv6, and blocking one IPv4 address returned for a hostname doesn’t guarantee coverage of other addresses that hostname may use later. Check the request log for the actual destination and address type before narrowing the domain condition or reviewing the IP condition.
Troubleshooting REJECT Misses and False Positives
Why is a request still going through PROXY after I added a rule?
On Home, check that Global Routing is set to Config, then verify the active configuration on Config. Trigger the request again and check which rule actually matched. If an earlier suffix rule routes the target through PROXY, move the exact REJECT rule above it.
Why is the ad container still visible even though the rule matched?
Check the request log from the time you triggered it: blocking an asset request doesn’t mean the app removes a container that’s already been drawn. If it still contains content, check whether it came from the cache, the page’s main response, or another hostname. Don’t block the hostname for the entire page just because an empty placeholder remains.
Why did blocking one request also break sign-in?
Remove the rule you just added and try signing in again, then compare the request log from the failed attempt. If sign-in also uses the blocked hostname or matched the same broad suffix rule, switch to a DOMAIN rule for a nonessential target only. If there’s no separate target, keep the host’s original action.
Does a successful Connectivity Test mean blocking is working?
No. It doesn’t verify an individual rule. A successful Connectivity Test doesn’t mean the target request matched REJECT. Trigger the action you want to check in the original app, then verify the actual destination, matched action, and result after removing the rule for comparison.