Shadowrocket REJECT Rules: How Domain Blocking Works and Its Limits

Learn how REJECT works in rule matching, how to write DOMAIN-SUFFIX and DOMAIN-KEYWORD rules, and when domain rules can’t block a request.

At a glance

REJECT is a policy that denies a connection after a rule matches; it is not a web content filter. In Shadowrocket, set Global Routing to Config, then place narrowly scoped domain rules before fallback rules to deny connections as intended. This guide is for users with a working configuration who want to block specific requests. It covers syntax, rule order, recovering from false positives, and verification.

What REJECT does: denies matching connections

A rule has a matching condition and an action. For example, DOMAIN-SUFFIX,example.com,REJECT matches the target domain, and the final REJECT denies that connection. It does not add the domain to a permanent system blocklist or rewrite the web page returned by a server.

Connection starts Traffic is routed through the app Target is identified Rules are checked in order Connection is denied

This process has two prerequisites: traffic must be within Shadowrocket’s scope, and the current routing mode must use the relevant rules. Select Config under Home → Global Routing to verify rules in the active configuration using the steps here. Proxy and Direct are not interchangeable with Config; for Scene, first check which configuration and policies the current scene uses.

Denying a connection does not remove page elements. If an image domain is blocked, the page may show an empty space, a loading error, or a placeholder; the app may also retry automatically. If both the page text and the target resource come from the same allowed domain, a domain-level REJECT rule cannot extract and block just one piece of text from an encrypted response.

Assess connection control separately from content handling

The examples here control whether a request can connect; they do not require HTTPS decryption. To determine whether a rule works, check the target connection and matching policy, not just how the page looks.

How to write DOMAIN, DOMAIN-SUFFIX, and DOMAIN-KEYWORD rules

Start with the narrowest condition. Use DOMAIN when you know the full hostname. Use DOMAIN-SUFFIX only when you want to block the domain and all its subdomains. DOMAIN-KEYWORD has a broader match scope; use it only when you have a clear reason, not just because a string looks like a resource name.

Rule examplesMatch scopeWhat to check
DOMAIN,ads.example.com,REJECT Exact hostname: ads.example.com Does not also match img.ads.example.com
DOMAIN-SUFFIX,example.com,REJECT example.com and its subdomains Does not match notexample.com
DOMAIN-KEYWORD,tracker,REJECT Targets with tracker in the domain May match multiple unrelated domains

Do not include https://, a port, or a URL path in the domain field. To block the host serving https://ads.example.com/banner.png, enter ads.example.com, not the full URL. DOMAIN-SUFFIX also does not need to be written as *.example.com.

3 fields
Domain rule format: type, match value, policy
2 scope options
DOMAIN-SUFFIX: the domain and its subdomains
0 paths
The domain match field does not include a URL path

In short: start with a specific hostname, then broaden if needed

If only ads.example.com is known to be problematic, start with DOMAIN. Consider DOMAIN-SUFFIX only after checking dependencies such as sign-in, APIs, and static resources on the same domain.

Where to put rules: check the order in the active Config

Under Home, confirm Global Routing is set to Config. Then open Config and check which configuration file is selected. Editing a different file or saving without selecting it can leave connection behavior unchanged even when the syntax is correct. Save a copy of the original configuration before editing, especially before replacing rules in bulk.

  1. In Config, find the active configuration, open its editor, and review the rules.
  2. If you edit the file as text, find the [Rule] section. Do not put rules in [General].
  3. Put precise exceptions before broader rules, and place REJECT rules before any broad rule that could match first.
  4. Save the configuration, confirm it is selected, and test with a new connection. Keep the existing outbound policies and fallback settings.

This is a standalone example of rule order, not a recommendation to replace your entire configuration. It deliberately sends help.example.com direct, then rejects other matching targets under example.com. The final FINAL,DIRECT line only illustrates where a fallback goes; keep your existing fallback policy in actual use.

[Rule]
DOMAIN,help.example.com,DIRECT
DOMAIN-SUFFIX,example.com,REJECT
FINAL,DIRECT

Standard routing rules are checked in order. Once a rule matches, its policy applies, and later rules cannot override it. So if DOMAIN-SUFFIX is first, help.example.com will also be rejected. If an earlier DIRECT rule matches the target, the request will use DIRECT before reaching the REJECT rule.

Check the rule contents

Section
[Rule]
Exact exception
DOMAIN,help.example.com,DIRECT
Suffix rejection
DOMAIN-SUFFIX,example.com,REJECT
Final fallback
FINAL,DIRECT

Put exceptions first and broad rules later; keep the existing fallback.

Check the active setup

Routing mode
Home → Global Routing
Mode to verify
Config
Configuration
The file currently selected in Config
Automatic connection
Settings → On Demand

On Demand manages conditions for connecting on demand; it does not replace domain rules.

How to verify REJECT: change one condition at a time

Compare new connections to the same target before and after a change; page load speed alone is not a reliable test. Browser caches, existing long-lived connections, and app retries can all affect what you observe. An existing connection that remains open does not, by itself, prove that the rule failed to match.

  1. Record a baseline: Note the full target domain, test time, and original behavior. Confirm that this is the hostname you intend to handle.
  2. Add one rule: Start with a DOMAIN rule for that host. Do not change DNS, the outbound protocol, or other routing rules at the same time.
  3. Start a new connection: Close and reopen the target page or app. If you need to reconnect Shadowrocket, note that active transfers will be interrupted.
  4. Check the result: Review the target and final policy in the available connection records, and see whether the resource fails to load. A single timeout may also be caused by the network.
  5. Run a comparison: Temporarily remove the new rule and start another connection. A consistent change in behavior when toggling the rule provides stronger evidence of a cause-and-effect relationship.

For HTTPS targets, the common destination port is 443, but the domain rules here do not specify a port. Do not write DOMAIN,ads.example.com:443,REJECT just because you want to block a particular HTTPS resource. If resources use different paths on the same domain, the domain rule affects them all, not just one file.

Separate expected behavior from observed results

For the example above, the expected result is DIRECT for help.example.com and REJECT for new connections matching the example.com suffix rule. This follows from the configuration; it is not a record of live network tests against these example domains.

When domain rules can’t block a request—and where false positives occur

A domain rule needs domain information to match. It may not match if the target uses an IP address directly, the request is outside the current processing scope, or the app switches to a different hostname. In these cases, first identify the actual connection target instead of repeatedly adding variations of the same domain.

IP-CIDR matches an IP address range, while GEOIP routes traffic based on an IP’s geographic location. Neither is a “stronger domain keyword.” For example, IP-CIDR,192.0.2.0/24,REJECT shows the address-range syntax; 192.0.2.0/24 is reserved for documentation and is not a real-service blocklist. Broadening a range that includes shared addresses can affect entirely unrelated connections.

DNS settings and REJECT are also different things. A resolution failure can cause an error before you finish verifying a rule; denying a connection after a domain rule matches does not necessarily block the DNS query. Seeing a DNS query once is not enough to conclude that REJECT failed.

In short: identify the actual target instead of broadening rules as a workaround

If a precise rule does not produce the expected result, check the domain, address, and matching policy on a new connection first. Do not immediately switch to a short keyword or a large IP range.

FAQ: rules not working, false positives, and configuration updates

Why can the page still open after I saved the rule?

First, confirm Config under Home → Global Routing, then check the selected file in Config. Close the target page and establish a new connection, then check whether the actual host matches the rule. The page may be cached, or only one subresource may have been blocked, so do not judge by whether the whole page opens.

How do I recover if DOMAIN-KEYWORD breaks sign-in?

Remove the keyword rule you just added and test the connection again. Once sign-in works, note the full hostname you actually need to block and use DOMAIN instead. If you do need a suffix rule, put necessary exact exceptions first and use DIRECT or an existing policy that matches your configuration.

Will a custom REJECT rule disappear after I update a subscription?

First, distinguish a server subscription refresh from a full configuration update; they are different operations. Fetching a full configuration again may replace local edits, while refreshing a server subscription does not automatically mean the rule file is overwritten. Back up the configuration before editing, then check the active file and rule order after an update. Subscriptions come from your service provider.

Why doesn’t On Demand automatically reject traffic according to my rules?

Settings → On Demand configures conditions for connecting on demand; it does not create REJECT rules. First confirm Shadowrocket is connected, then check Home → Global Routing and the active configuration in Config. Automatic connection and routing after connection are separate things to verify.

A quick checklist before and after editing

The goal is not to maximize the number of rejection rules. Keep entries with clear purposes and explainable scope so they are easy to review. If a legitimate feature stops working, undo the latest change first, then narrow the match condition one rule at a time. When working with existing PROXY policies or custom policy names, use valid names from the current configuration; do not rename other policies just to add REJECT.

For more routing keywords, see the rule reference. For steps starting with connection permissions and choosing a configuration, see the tutorials. The domains in this article are syntax examples, not a blocklist to import as-is.

Download Shadowrocket