This guide uses Shadowrocket on iPhone and iPad. It’s for users who have already connected manually and want to manage the VPN tunnel automatically based on network conditions. First, understand the difference between On Demand and Config routing. Then set up rules to disconnect on a specific Wi-Fi network, connect on cellular, or trigger a connection for selected domains. Finally, test rule order and troubleshoot with repeatable network-switching steps. Get subscriptions from your service provider; automatic connection settings do not check whether a server is available.
1. On Demand controls connections; Config controls traffic routing
Settings → On Demand lets you configure conditions for automatic connections. When enabled, the system evaluates the VPN configuration in response to network changes or qualifying connection requests; Shadowrocket does not need to remain in the foreground. On Demand determines when to establish or disconnect the tunnel, not which outbound policy a website uses.
Once the tunnel is up, traffic handling still depends on Home → Global Routing. Proxy routes traffic through the global proxy, while Direct sends it directly. Config applies the rules in your configuration, and Scene depends on the configured scene. When troubleshooting, note the selected option instead of checking only whether the connection switch is on.
For example, DOMAIN-SUFFIX,example.com,DIRECT means matching traffic uses DIRECT; it does not disconnect the VPN. Conversely, an On Demand trigger can establish a connection without guaranteeing that all traffic will pass through a proxy server. GEOIP, IP-CIDR, and FINAL are also traffic rules, not conditions for automatically connecting or disconnecting based on network changes.
2. Establish a working manual connection first
On Demand cannot fix an incorrect server address, port, password, or TLS setting. If a manual connection does not work, automatic triggers will only repeat the same failure or retry loop. Temporarily turn off On Demand and establish a repeatable baseline before testing.
- In
Home, confirm that you have a working server. If you use a subscription, get it from your service provider and complete the import and any required updates first. - Select the server you want to test as the default and turn on the connection switch. The first time you connect, follow the system prompt to allow a VPN configuration to be added.
- Run
Connectivity Test, then open a website you know should work. Test results apply only to the specific test target, so also check the requests your apps actually make. - Note the current
Global Routingoption andConfig. Keep both unchanged during testing so routing changes are not mistaken for an automatic connection problem. - Test manually on the target Wi-Fi network and on cellular. If your iPad does not support cellular data, skip the cellular test; disconnecting from Wi-Fi does not count as a successful cellular connection.
3. Disconnect on specific Wi-Fi; connect on cellular
A common setup is to keep the tunnel disconnected on a trusted home Wi-Fi network and connect automatically when switching to cellular. First, copy the network name, or SSID, from your system Wi-Fi settings. Match capitalization, spaces, and suffixes exactly. If the router broadcasts separate names for its two bands, add a rule for each one.
Go to Settings → On Demand and configure the network type, SSID condition, and connection action in the rule editor. The examples below use the system On Demand meanings of Connect and Disconnect. Available controls depend on the current interface; these descriptions are not Config text to copy and paste.
Rule A: Home Wi-Fi
- Location
- Settings → On Demand
- Network type
- Wi-Fi
- Example SSID
- Home-WiFi
- Action
- Disconnect
- Order
- Place before any general Wi-Fi rules
Home-WiFi is an example name. Replace it with the actual SSID before saving.
Rule B: Cellular
- Location
- Settings → On Demand
- Network type
- Cellular
- SSID condition
- Leave the Wi-Fi name condition blank
- Action
- Connect
- Requirement
- Cellular data is enabled and available
A cellular connection uses your existing server and configuration; it does not create new server details.
- Save only Rule A first, enable On Demand, and switch from another network to the target SSID. Check that the VPN disconnects as expected.
- Then add Rule B, turn off Wi-Fi, and confirm that the system has switched to cellular data rather than going completely offline.
- Check the system VPN status and make a new web request. Once the tunnel is established, run
Connectivity Test. - Reconnect to the home Wi-Fi network and check that Rule A takes effect again. After each switch, wait for the network to obtain an address and default route; don’t rapidly toggle the switch.
4. A domain trigger does not disconnect as soon as you leave a website
Domain-based On Demand is for cases where you don’t want to keep the tunnel up all the time, but want the system to evaluate a connection when certain domains are accessed. In the system’s On Demand model, domain evaluation typically uses EvaluateConnection, with rules that determine behavior such as ConnectIfNeeded or NeverConnect. Configure this using the domain-based On Demand options actually available in Shadowrocket. Don’t enter these system terms in the regular Config rules section.
- Domain condition: Enter the domain format required by the interface, such as the example value
example.com. This field expects a domain, not a URL; don’t includehttps://, a path, or query parameters. - Resolution condition: Some On Demand behaviors use the system’s DNS results to decide whether to connect.
ConnectIfNeededdoes not mean “always Connect whenever a domain is seen.” Test it against the conditions provided by the current rule. - Trigger limits: Accessing an IP address, resolving a domain inside an app, or making a cached request may bypass the expected system domain evaluation. Start with a new browser request for comparison.
- Disconnect limits: Closing a browser tab does not immediately disconnect the VPN. Background connections, existing sessions, and the system’s tunnel management can all affect the resulting state.
To test a domain trigger, temporarily remove broad Connect rules for the test network. Otherwise, the tunnel may already be connected due to network conditions, so you cannot tell whether the domain triggered it. Similarly, a matching Disconnect rule earlier in the list may prevent the domain evaluation from running.
5. Check rule order when multiple rules are present
The system evaluates On Demand rules in their listed order, and the first matching rule determines the action for that evaluation. Put a specific SSID condition before an “all Wi-Fi” rule. A network condition that evaluates domains must not be preempted by a broader Connect or Disconnect rule. Don’t interpret “ignore this condition” as disconnecting, and don’t assume every action continues to the next rule.
| Order | Matching condition | Action and result |
|---|---|---|
| 1 | Wi-Fi with SSID Home-WiFi | Disconnect; once the home Wi-Fi rule matches, later broad rules are not used |
| 2 | Cellular | Connect; attempts to establish the tunnel when cellular data is available |
| 3 | Other Wi-Fi networks | Configure domain evaluation only if needed, or specify a connection action explicitly |
The table is an example for planning rules; not everyone needs to keep a third rule. If the third rule is Connect for all Wi-Fi networks, network conditions will establish the tunnel on other Wi-Fi networks, so this is no longer a domain-only On Demand setup. To prevent automatic connections on other networks, specify the action explicitly instead of guessing what happens when no rule matches.
Don’t confuse two kinds of top-down rule order
On Demand rule order determines connection actions; Config rule order determines traffic policy. Both may be processed in order, but they match different things and run at different times. The following is only a Config syntax example; it will not disconnect on a particular SSID or connect automatically on cellular:
DOMAIN-SUFFIX,example.com,DIRECT
IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
GEOIP,CN,DIRECT
FINAL,PROXY
Before testing, confirm that the policy mapped to PROXY is valid in your current configuration, and set FINAL according to your needs. Don’t replace the entire Config just to test On Demand; if domain access changes, you won’t be able to tell which layer caused it.
6. Test with a consistent procedure, not just the switch
Record at least three things during testing: the current network, the system VPN status, and the result of an actual request. A connected VPN only confirms the tunnel state, not that the server is usable. A webpage opening does not prove it used a proxy; the request may have matched DIRECT or come from a cache.
- Prepare: Record the rule order, confirm the manual connection works, then enable On Demand. Don’t enable another VPN configuration for comparison at the same time.
- Test home Wi-Fi: Switch from cellular to the target SSID, wait until the network has an address, and check whether the expected disconnect action occurs.
- Test cellular: Turn off Wi-Fi, confirm cellular data is available, and make a new request. Check that the tunnel connects automatically and passes
Connectivity Test. - Test domains: Switch to a network set up for domain evaluation. Confirm no earlier rule has already connected or disconnected the VPN, then request the test domain and a comparison domain.
- Repeat the network switches: Run through the same sequence again. If only the second run differs from the first, check for caching, existing connections, and whether the network switch completed.
These are verification steps, not a promise of results on a particular device. Status bar indicators vary by device; check the system VPN settings if you need to confirm the actual connection state. Don’t use a fixed number of seconds as a universal wait time, and don’t interpret a failed request during tunnel startup as a permanent outage.
7. Troubleshoot automatic reconnects, SSID mismatches, and domain triggers
Why does the VPN reconnect after I turn it off in Home?
First, pause On Demand in Settings → On Demand, then turn off the connection switch in Home. Also check whether On Demand is still enabled in the system VPN configuration. Turning off the Home switch alone does not necessarily remove system trigger conditions; a matching Connect rule may establish the tunnel again.
I entered my home Wi-Fi details. Why doesn’t the VPN disconnect?
Check the current SSID in system Wi-Fi settings. You may be connected to another band with a different suffix. Then check that the specific SSID’s Disconnect rule comes before the Connect rule for all Wi-Fi. Save your changes, disconnect from the network, and reconnect to test.
The VPN says it’s connected on cellular, but webpages keep timing out. What should I do?
Pause On Demand, keep the same server selected, connect manually, and run Connectivity Test. If it still fails, check cellular data, server settings, and your service provider’s status. If manual connection works, check Global Routing and the current Config. Don’t try to hide an unreachable server by rearranging On Demand rules.
A domain didn’t trigger a connection. Should I keep adding domains?
First, make sure the domain evaluation rule can run: no earlier broad Disconnect or Connect rule should match. Check that the entry contains no URL path, then test again with a new request. Also confirm that the selected option is ConnectIfNeeded, which depends on DNS resolution, rather than unconditional connection.
What if public Wi-Fi requires sign-in and automatic connection keeps failing?
Temporarily turn off On Demand and the VPN. Sign in to the Wi-Fi network in a browser and confirm that regular internet access works, then restore On Demand. If this happens often, configure a separate matching action for these networks. An automatic tunnel connection cannot replace a captive portal sign-in when the network has not yet granted internet access.
8. Keep a rollback option before adding more rules
A stable setup should make every connection change easy to explain. Start with two rules you can verify: disconnect on a specific SSID and connect on cellular. Once repeated network switches work, add domain conditions or rules for other Wi-Fi networks. Change one condition at a time and record the old and new rule order. If something goes wrong, restore the last verified setup.
- Pause automatic connections: Turn off On Demand in
Settings → On Demand. If needed, check the On Demand status in the system VPN configuration, then control the switch manually in Home. - Keep your traffic settings: Don’t delete the current Config or change server protocols while testing automatic connection and disconnection.
- Protect sensitive information: When documenting a problem or asking for help, share the rule order, network type, and symptoms. Don’t disclose your full subscription URL, password, or private key.
- Platform differences: This guide covers iPhone and iPad. Network behavior and system settings may differ on Mac, Windows, Android, and Linux, so don’t assume their system menus work the same way.
Shadowrocket is a closed-source commercial app. The iPhone and iPad version costs $2.99 as a one-time App Store purchase. The developer is Shadow Launch Technology Limited; check the App Store listing for system requirements. The Mac (Apple silicon and Intel), Windows, Android, and Linux versions are free. Buying the app does not include a service plan; get subscriptions from your service provider. This site does not provide, sell, or recommend servers or subscriptions.