On Demand determines when the system establishes or disconnects the VPN tunnel; it does not determine the outbound policy for each connection. This guide uses Settings → On Demand on iPhone / iPad as its reference and is for users with a working configuration who want connections triggered by Wi-Fi, cellular networks, or domains. Verify a manual connection first, then configure specific conditions and fallback actions, and test network changes and domain resolution separately. Mac, Windows, Android, and Linux users should follow their device settings and background behavior rather than applying these system VPN rules directly.
On Demand vs. Global Routing
In Shadowrocket, On Demand manages the connection lifecycle, while Global Routing controls how traffic is handled after the tunnel is established. Seeing the system VPN indicator only means the tunnel is connected; it does not prove that a particular website is using a proxy. Likewise, being able to open a webpage directly does not prove that On Demand was triggered.
In Home, first confirm that an existing server connects, then check Global Routing. Proxy, Direct, Config, and Scene are different modes, not four On Demand triggers. Choose Config to route traffic according to its Rules; Proxy and Direct are for routing all traffic through a proxy or connecting directly. Scene relates to scene settings and is not the same as system On Demand. During troubleshooting, stick with a known-working Config so two layers of automation do not affect the results at once.
Before you begin: verify a manual connection and system permissions
On Demand cannot fix an incorrect server address, invalid credentials, or an unreachable port. If a manual connection fails, adding automatic triggers will only repeat the same failure. This guide assumes you already have a provider and subscription; it does not cover finding or recommending services.
- In Home, select an existing server, temporarily turn off On Demand, and connect manually. The first time you connect, allow the VPN configuration when prompted by the system.
- Check the current configuration and Global Routing. Visit a known working destination and confirm the request succeeds—not just that the switch turns on.
- If you use a subscription, first confirm that the existing server settings are up to date and work manually. Avoid changing the subscription, DNS, and On Demand at the same time, so you can identify the cause of any issue.
- Go to Settings → On Demand and review the conditions and actions available on your device. After saving, check the corresponding On Demand status in the VPN configuration in system Settings.
The VPN settings location on iPhone / iPad may vary by system version; search for VPN in Settings if needed. Check the configuration associated with Shadowrocket, not an old, unrelated entry. Use the rule descriptions here to guide your setup, but follow the field layout in the current app. These examples are not configuration files you can import.
Set Wi-Fi and cellular rules: put specific conditions first
A common setup is to disconnect on a specific home Wi-Fi network and connect automatically on other Wi-Fi networks and cellular data. Enter the actual network name as the SSID, such as Home-WiFi. Do not enter the router's admin address, Wi-Fi password, or device name. Match the capitalization, spaces, and symbols shown by the system; do not replace a hyphen in the name with a similar-looking dash.
Exception for a specific Wi-Fi network
- Location
- Settings → On Demand
- Network condition
- Wi-Fi
- Example SSID
- Home-WiFi
- Action
- Disconnect
- Order
- Place before general Wi-Fi rules
Use this only if you want the tunnel disconnected on this network. A matching network name does not mean the network is trusted.
Cellular connection rule
- Location
- Settings → On Demand
- Network condition
- Cellular
- SSID condition
- Leave blank
- Action
- Connect
- Test
- Turn off Wi-Fi and make a new request
Cellular rules match the network type, not a Wi-Fi name.
To connect on other Wi-Fi networks too, add a general Wi-Fi Connect condition after the specific SSID exception. If you add multiple conditions to one rule, check whether they must all match. Do not combine a cellular condition and an SSID in a way that requires both to be true. The system must be able to read the current SSID to evaluate the rule correctly. If the app or system asks for related permissions, check the prompt and grant access as needed.
- Connect to
Home-WiFi, make a new request, and check whether the VPN status matches the expected Disconnect action. - Switch to a Wi-Fi network with a different name and check the general Wi-Fi Connect condition.
- Finally, turn off Wi-Fi. Once cellular data is available, make a new request and check the Cellular condition.
- Do not treat a failure with no network in Airplane Mode as a broken cellular rule. First make sure mobile data can access the internet.
How to order multiple On Demand rules
The system evaluates On Demand rules in order. A broad condition near the top may match before a more specific rule below it can run. List exceptions first, followed by general conditions. After saving, test each branch separately. Do not test only the last rule or assume that repeating a condition will make it more likely to trigger.
| Order | Example conditions | Action | Expected result |
|---|---|---|---|
| 1 | Wi-Fi with SSID Home-WiFi | Disconnect | Disconnect the tunnel on this network |
| 2 | Any other matching Wi-Fi network | Connect | Connect on other Wi-Fi networks |
| 3 | Cellular | Connect | Connect on cellular networks |
| 4 | All other cases | Choose a fallback action that fits your needs | Specify what happens when no rule matches |
Bottom line: put the most specific exceptions first
If the specified Wi-Fi still connects automatically, move its SSID Disconnect condition above the general Connect condition, then switch networks and test again. Do not change server settings right away.
Connect requests a connection; Disconnect disconnects. Ignore does not mean Disconnect and cannot guarantee that an existing tunnel will disconnect immediately. There may also be a short delay between a network change, system evaluation, and a new request. During testing, record the network name, matching condition, expected action, and actual status. Do not rely only on the status bar at the moment you switch networks.
Trigger by domain: configure separately from DOMAIN-SUFFIX routing
Domain-based triggering lets the system decide whether to establish a VPN before the tunnel is up, based on connection evaluations for specified domains. It is not keyword matching in a browser address bar, and visiting any subdomain does not guarantee an immediate connection. System domain evaluation for On Demand is generally tied to name resolution; caching, existing connections, and an app's own resolution method can affect what you see.
- In Settings → On Demand, check whether domain evaluation conditions are available. Domain-based On Demand generally uses the system's EvaluateConnection and ConnectIfNeeded mechanisms. Available options depend on the page on your device.
- Enter a hostname in the domain field, such as
example.com. Do not includehttps://, a path, or query parameters. If the interface distinguishes exact domains from suffixes, configure them according to the field descriptions; do not assume they are equivalent. - First check how the target hostname resolves on the current direct connection. ConnectIfNeeded does not mean that every visit triggers a connection unconditionally; if the system's evaluation criteria are already met outside the tunnel, it may not connect.
- Close any existing page for the target and end long-lived connections. Then make a new request and check the system VPN status. Refreshing a page already in the cache is not a reliable test for domain triggering.
If the domain evaluation rule comes after a rule that connects on all Wi-Fi networks, the system may connect based on the network condition first, so the domain rule will not appear to connect only when the domain is accessed. To test domain-based On Demand, temporarily remove broad conditions that connect too early, while keeping the original settings so you can restore them. If the current page has no domain evaluation option, do not use the SSID field as a substitute.
After the tunnel connects, Rules in Config determine whether a destination uses DIRECT or a proxy policy. The example below shows routing syntax, not On Demand settings; PROXY must be the name of a policy available in your current configuration. Do not overwrite your existing configuration—use the example only to understand the difference between these two layers.
[Rule]
DOMAIN-SUFFIX,example.com,PROXY
IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
GEOIP,CN,DIRECT
FINAL,PROXY
DOMAIN-SUFFIX matches domain suffixes, IP-CIDR matches address ranges, GEOIP matches by IP geolocation, and FINAL is the last-resort rule. Adding DOMAIN-SUFFIX to Config does not create a system On Demand condition. Likewise, establishing a connection with On Demand does not replace these routing rules.
On Demand not working: troubleshoot by symptom
First identify where the problem occurs: On Demand does not trigger, the connection fails after triggering, or access fails after connecting. Each points to different checks. Use a controlled test to record the network type, VPN status, and request result before and after a change. The steps below are a troubleshooting sequence, not a guarantee for every network environment.
Why does it reconnect automatically after I turn it off manually?
The current network may still match a Connect condition. First turn off On Demand in Settings → On Demand, then disconnect manually. If you want to disable it long term, also check the On Demand status in the system VPN configuration. Turning off the connection switch in Home does not remove automatic connection conditions.
Why doesn't Disconnect work on my home Wi-Fi?
Check the actual SSID, permissions needed to read network information, and the position of the exception rule—in that order. Make sure your phone has not switched to a band with a different network name, then check for a general Connect condition higher in the list. Change one thing at a time, save, and switch networks again to test.
Why does it stay on Connecting after I switch to cellular?
First turn off On Demand and test the same server manually. Check the server address and the port and protocol settings provided by the service, along with the system date and time. If the service explicitly uses port 443, enter 443; do not change other valid ports to 443 just because it is common in examples.
Why doesn't visiting the target domain connect automatically?
Check that domain evaluation is actually configured, rather than only adding DOMAIN-SUFFIX in Config. Then check whether direct DNS resolved successfully, whether the page is cached, and whether the app is reusing an existing connection. If the ConnectIfNeeded conditions are not met, no connection attempt is not necessarily a fault.
Why can't I access anything even though the VPN is connected?
Check the current server and Global Routing in Home, then review rule order and policy names in Config. If the same destination fails with a manual connection too, continue checking DNS, protocol settings, and reachability. Repeatedly toggling On Demand will not fix a connection-layer problem.
Verify your setup and check platform coverage
A small, maintainable setup is usually easier to verify than a stack of conditions. Start with one clear network condition and confirm that it produces the same result repeatedly before adding a second exception. To restore the previous behavior, turn off On Demand and switch back to a manual connection method you have already verified. Before deleting a system VPN configuration, make sure the connection settings are still saved in the app.
- Wi-Fi exception: the expected action applies when the SSID matches, and no longer applies if the network name changes.
- Cellular: mobile data is available, and a triggered connection completes a real request rather than just showing Connecting.
- Domain evaluation: test separately from general Connect conditions and distinguish DNS evaluation from Config routing.
- Recovery: record rule order and the original switch states so you can disable automatic connections and return to manual mode.
Shadowrocket is available for iPhone / iPad, Mac (Apple silicon and Intel), Windows, Android, and Linux. The system On Demand steps in this guide apply to iPhone / iPad. The iPhone / iPad app costs $2.99 as a one-time App Store purchase; the Mac, Windows, Android, and Linux versions are free. Check the App Store listing for iPhone / iPad system requirements. The App Store developer is Shadow Launch Technology Limited. A one-time app purchase is not a service subscription; this guide covers connection controls for an existing configuration only.