reference / config.yaml
Clash Configuration Guide
mihomo YAML fields, references, and processing order
Installing a client or importing a subscription for the first time? Start with the quickstart guide. If your configuration is already running and you need to find where a field belongs or which part of the traffic flow it affects, use the contents below to jump to the relevant section. The examples follow the configuration read by the core; client interface options and override methods may differ.
YAML structure and configuration loading
Identify configuration types by their top-level keys
A complete configuration is a top-level mapping. Listener ports and the operating mode go at the root; DNS options live under dns; proxies and groups each use a list; and rules form an ordered list of strings. Think of the file as a traffic flow: an app sends a connection through an entry point to the core, the core reads the destination, a rule specifies an outbound, and a group selects which outbound to use.
This is a standalone starter configuration. It needs no remote service, and its only group references the built-in DIRECT outbound. Keeping a direct-only baseline helps isolate two kinds of problems: if the core hasn't opened a local listener, fix that first; if the baseline works and problems appear only after adding proxies, there's no need to recheck every indent in the file. The ports shown are chosen values, not defaults for every client.
mixed-port: 7890
allow-lan: false
mode: rule
log-level: info
proxy-groups:
- name: PROXY
type: select
proxies:
- DIRECT
rules:
- DOMAIN,example.com,DIRECT
- MATCH,PROXY
Leave a space after each colon and align keys at the same level. Start list items with a hyphen and a space. In the example, name, type, and the group's proxies all belong to the same list item. The group's proxies value is a list of names, while the root-level field with the same name is a list of proxy definitions. When you see a repeated key, check its parent first: don't put a proxy's connection settings in the group's member list.
Use spaces for indentation; two spaces per level make the file easier to review. Quote descriptive names that contain a colon followed by a space, a hash sign, or text a parser might interpret as a boolean. Keep ports as integers and use true or false for switches. Quoting every scalar may look tidy, but it can turn booleans and numbers into strings, causing type errors when the core reads those fields.
Distinguish imported files, remote sources, and the active configuration
A remote subscription is a configuration source, but it isn't necessarily the file the core currently reads. A GUI client may download the original, merge local settings, then pass the result to the core. Being able to save a file in an editor doesn't mean it's active. If a port reverts after restart, check the selected profile and client settings before editing the download cache again. If the client offers a preview of the active configuration, use it to verify the field.
If an import fails, first check whether the file is actually YAML. A subscription URL opening in a browser doesn't guarantee that its response is a configuration: it could return a login page, an error page, or an encoded list of proxies. A rule provider file starting with payload can't replace a complete configuration either. For where to import each source, see the subscription import steps and subscription links vs. configuration formats.
Check the syntax, then verify startup
With a command-line core, run the following command from a test directory containing config.yaml. -d sets the working directory and affects relative resource paths; -f selects the configuration file to check; and -t tests the configuration without starting a persistent service. If resources or providers need to load during initialization, read the full error output to distinguish YAML structure issues, unresolved name references, and unavailable resources.
mihomo -t -d "$PWD" -f "$PWD/config.yaml"
The line reported for a syntax error is often where the parser first detects a conflict; the actual mistake may be on the previous line, such as an unclosed quote or a list item indented at the wrong level. Check the structure around the reported line and identify the affected level. If one change triggers a cascade of errors, undo it and rerun the check rather than fixing each follow-on error and losing the original intent.
Don't redeclare an existing root key at the bottom of the file to override its value. Duplicate rules or dns keys may be rejected, or a processing step may keep only one copy; either way, the result can differ from what you intended. To temporarily disable a section, use its enable switch or remove it in a separate test copy. Commenting out only a parent key while leaving its children can leave them without the right parent.
Listener ports, access, and operating modes
Entry ports determine how apps connect to the core
mixed-port accepts both HTTP proxy and SOCKS connections on one port. port and socks-port open separate listeners for their respective protocols. A mixed port is enough for most desktop setups; add separate listeners only if an app needs distinct entry points or you want to test the two protocols independently. Don't assign the same port to two listeners on the same address.
| Field | Controls | Common confusion |
|---|---|---|
mixed-port | Mixed proxy entry point for apps connecting to the core | Not the remote proxy server's port |
external-controller | Address and port for the core's management API | Not for a browser's proxy settings |
allow-lan | Whether other devices can access the proxy listener | Doesn't configure proxy settings on another device |
mode | How connections entering the core select an outbound | Doesn't change how apps send traffic to the core |
The proxy listener and management API serve different purposes. If a control panel can read proxy groups, it can reach the management API; that doesn't prove the browser is using the right proxy address. Conversely, the proxy listener may still handle connections even when the management panel is temporarily unavailable. When troubleshooting, note which address, port, and protocol failed instead of lumping both issues together as “the client can't connect.”
For local use, keep allow-lan: false and have apps use the loopback address. Enable LAN access only when sharing with trusted devices; bind to the appropriate network interface and restrict access with your firewall. A loopback address on another device points back to that device, not to the machine running mihomo. Keep the control interface on loopback unless remote management is needed, so devices without administrative access can't see your configuration or runtime state.
mixed-port: 7890
allow-lan: false
mode: rule
log-level: info
Modes only affect connections that have entered the core
rule selects an outbound by rule order; global sends connections through the global selection; and direct sends connections that enter the core directly to their destinations. Global mode is useful for a short comparison to see whether a proxy works when rule matching is bypassed, but it can't verify rule priority. Switching to direct mode doesn't disable the system proxy: an app may still send requests to the local port, with the core connecting directly to the destination.
GUI clients often remember the last mode selected in the panel. If the file specifies rule mode but connection records keep showing a global selection, check both the runtime status and the configuration actually loaded. For testing, change one variable at a time and keep the destination, entry point, and proxy the same; restore the original mode afterward. Changing modes and proxies together makes it hard to tell which change fixed the issue.
Use explicit proxy requests to isolate system proxy issues
curl --max-time 15 --noproxy "" --proxy http://127.0.0.1:7890 https://example.com/
curl --max-time 15 --noproxy "" --proxy socks5h://127.0.0.1:7890 https://example.com/
These commands use the HTTP and SOCKS listeners, respectively. socks5h sends the destination hostname to the proxy for resolution, while socks5 usually resolves it on the client side. Clear proxy exclusions for this request so environment settings don't bypass the specified listener. Both commands require the mixed port to be listening; if you use separate ports, substitute the relevant address.
If the connection is refused immediately, check that the process is running and the address is correct. If startup reports that the address is already in use, compare the current port with listeners from older processes; don't rely on refreshing the browser. If an explicit request succeeds but a regular app fails, check whether the app honors the system proxy or uses its own settings. For a step-by-step system proxy check, see Troubleshooting: connected but can't open websites.
Temporarily raise the log level to debug, reproduce the failure once, then restore info. The listener, destination, and outbound in the logs answer three questions: did the connection arrive, where was it going, and which route handled it? Load testing or leaving verbose logs on increases output and may record more destinations. Redact real domains, addresses, and configuration sources before sharing screenshots.
Existing connections in the same app may not respond immediately to changes in ports or mode. A browser may reuse established connections, and an ongoing download won't switch routes on its own. Retest with a new request, closing and reopening the app if needed. If only a program in another user session is affected, check which session's proxy settings it reads rather than assuming the port has failed at random.
DNS upstreams, address mapping, and resolution policies
Separate the three DNS tasks
dns.enable enables the core's DNS module. nameserver specifies upstream resolvers for general domains. If an encrypted upstream uses a hostname, the core first needs to resolve the upstream itself; default-nameserver provides that bootstrap resolution. If a remote proxy's server is a hostname, proxy-server-nameserver can give proxy hostnames a separate resolution path.
Keeping these tasks separate avoids a common dependency loop: you need a proxy to reach the resolver, but you need that resolver to look up the proxy's address. Configure a bootstrap resolver reachable from your current network, and give proxy hostnames their own resolution path. Don't assume an upstream is reachable just because of its protocol; first check whether it can connect and respond on your network, then consider changing the request route.
dns:
enable: true
listen: 127.0.0.1:1053
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
fake-ip-filter:
- "localhost"
- "*.lan"
default-nameserver:
- 223.5.5.5
nameserver:
- https://dns.alidns.com/dns-query
proxy-server-nameserver:
- 223.5.5.5
nameserver-policy:
"+.example.com":
- 223.5.5.5
Here, listen only opens a local DNS listener; it doesn't automatically route the operating system's DNS queries to that port. Most system DNS settings accept a server address, not an arbitrary port. To test 1053, use a tool that supports specifying a port. For system-wide DNS interception, configure the client or a controlled local resolver to forward queries according to the actual interception setup. Setting a loopback address alone doesn't mean queries will reach the core.
Decide whether fake-IP suits the domain
fake-ip assigns queries an address from a mapping range. When a subsequent connection is captured by the core, the mapping lets the core recover the original domain so domain rules can match. In this example, an address in the 198.18.0.0/16 range is expected. If an app gets a mapped address but its connection doesn't pass through the core, the connection can fail: that address isn't the one published by the remote site.
The alternative, redir-host, returns the real address to the app. It's a better fit for apps that need real addresses, but the original domain can't reliably be inferred from a single destination address. When multiple sites share an address, domain-based routing depends on whether domain information remains available for the connection. Don't change the DNS mode, ruleset, and interception method all at once; otherwise, it's hard to tell whether the domain was lost during address resolution or became unavailable after the connection started.
fake-ip-filter skips address mapping for selected domains; it isn't a direct routing rule. If a repository or printer service needs a real address, add its confirmed hostname to the filter, then verify that the upstream resolver can resolve it. If a public upstream doesn't know a local network name, changing the filter alone will still return no result. Forwarding that suffix to a resolver familiar with the local namespace is a separate fix.
Find the specific query and matching scope
nameserver-policy routes specified domains to different upstream resolvers. In this example, +.example.com covers both the apex domain and its subdomains. It changes which resolver handles a query, not the outbound used for the subsequent connection; rules and groups still determine the route. A broad policy for unrelated domains often causes only some domains to fail while requests to public sites continue to work.
dig @127.0.0.1 -p 1053 example.com A
dig @127.0.0.1 -p 1053 example.com AAAA
First confirm that the local port responds, then distinguish a timeout, an explicit “domain not found” response, and a response with no record of the requested type. The commands check IPv4 and IPv6 records separately; an empty result for one record type doesn't mean DNS is completely down. If the commands resolve the name but the browser behaves differently, check its cache, separate secure DNS settings, and the query path into the core. A browser result is no substitute for testing the listener directly.
After changing an upstream, the system, browser, and core may all retain old results. For a clean retest, close the app holding old connections and use the same tool to request the same record type. Record the old and new results and which upstream was used. If connection logs show only an address and no hostname, check the rules section for a match rather than repeatedly broadening address ranges or switching upstreams just to make a rule match.
For the same domain, a LAN resolver and a public resolver may be expected to return different answers. For example, an internal service might have a private address only while you're on the office network. Before comparing results, confirm which namespace the answer should come from instead of judging by how the address looks. Retest after leaving the office network too, so a resolver reachable only there doesn't remain your default for every domain.
Proxy fields and providers
A proxy name is a reference; a server address is a connection parameter
Root-level proxies defines the available outbounds. Each entry's name is an internal configuration name; type selects the protocol; and server and port tell the core where to connect. Groups reference proxy names, not server addresses. If you rename a proxy without updating its references, groups won't find the old member. Changing the server usually doesn't require updating references, but the new server's protocol and authentication parameters must still match its definition.
This example uses a SOCKS service already running locally, so it doesn't depend on a subscription URL. Before testing, confirm that 127.0.0.1:1080 is actually another service's listener, not mihomo's own entry point reused as an outbound. Pointing a proxy back at itself can send connections into the core recursively; a flood of repeated connections in that case doesn't mean the remote server is unstable. Keep group and proxy names distinct.
proxies:
- name: LOCAL-SOCKS
type: socks5
server: 127.0.0.1
port: 1080
udp: false
proxy-groups:
- name: PROXY
type: select
proxies:
- LOCAL-SOCKS
- DIRECT
udp declares whether this outbound uses UDP; a website loading successfully doesn't prove that the same proxy can handle an app's UDP sessions. When debugging real-time communication, first identify the transport the app needs, then verify that the local interception, protocol, and server all support it. Setting the boolean to enabled only tells the configuration to try using that capability; it can't add support on the server.
Set additional parameters for the protocol
SOCKS or HTTP proxies with authentication may have username and password fields; other protocols use their own authentication methods. Get the remote host, transport, handshake parameters, and authentication fields from the same known-good configuration. Don't copy fields between different protocols and assume they mean the same thing. If a connection test reports a handshake error, check that the second configuration didn't carry over the old protocol's port, transport path, or authentication parameters.
When an outbound uses TLS, distinguish the server address used for dialing from the service name used in the handshake. The address can point to a specific host while certificate validation still needs to match the expected domain. A wrong service name, incorrect system time, or connection to a different service can all cause a handshake failure. Use the logs to determine whether the failure occurred during resolution, connection, or handshake; don't weaken validation to hide a configuration error.
Use a provider to manage frequently updated proxies
proxy-providers registers proxy sources separately, and groups include those sources with use. A provider name is an alias for the source, not the name of a proxy in it; putting it in a group's proxies list won't expand it automatically. The example uses a local file to show how the pieces fit. Put the file in the core's working directory, then merge the group into the main configuration as needed. Relative paths are not relative to the browser's download directory.
proxy-providers:
local-pool:
type: file
path: ./nodes.yaml
proxy-groups:
- name: PROXY
type: select
use:
- local-pool
proxies:
- DIRECT
proxies:
- name: LOCAL-SOCKS
type: socks5
server: 127.0.0.1
port: 1080
udp: false
The proxies fields in the main configuration and the proxy source file are both lists of proxy definitions, but they serve different roles: the main file declares members directly, while the provider loads them. For an HTTP-based source, the refresh interval, source URL, and cache path belong to the provider itself. Don't let two sources share a cache file, or the group members loaded from stale cache may be unpredictable. Keep source URLs that contain personal information in your own configuration environment.
Having members in a group proves only that its list exists, not that it has just been updated. After an update fails, runtime status may still show the last successfully loaded content. Check the source's update time, proxy test results, and actual connection logs separately. If a fixed name is referenced, check whether the source renamed it. When the provider can generate the full member list, there's no need to copy the entire list locally.
If only a few members fail, test a known-working member in the same group for comparison. If the whole group fails, check the source and shared resolution path first, then the local clock or port. A single timeout doesn't identify the cause of a remote service problem. See How to troubleshoot proxy timeouts and connection failures to separate proxy parameter issues from local network problems.
Proxy group selection logic and testing limits
Use stable group names in rules
proxy-groups provides stable names for selecting among outbounds. If a rule targets only PROXY, you can change group members without editing every rule. A select group lets users choose a member; it can contain proxy names, built-in outbounds, or other groups. Group references create dependencies: a primary group can depend on a test group, but the test group can't depend back on the primary group. A cycle leaves no outbound to reach.
Continuing from the previous section, if the main configuration already has a LOCAL-SOCKS proxy, replace the existing group block with the example below. It keeps one manual selection and one automatic group so you can compare the two routes. For production traffic that must use a specific outbound, decide whether direct should be a candidate based on the requirements; adding it to an automatic group allows it to become the actual outbound when its test results qualify.
proxy-groups:
- name: PROXY
type: select
proxies:
- AUTO
- LOCAL-SOCKS
- DIRECT
- name: AUTO
type: url-test
url: https://www.gstatic.com/generate_204
interval: 300
tolerance: 80
proxies:
- LOCAL-SOCKS
- DIRECT
Choose between latency testing, failover, and load balancing
url-test automatically selects a member based on probe results. url is the probe target, interval is in seconds, and tolerance is in milliseconds. Tolerance helps keep the current member: if the speed difference is small, a minor fluctuation won't trigger a switch. Very short intervals increase requests and fluctuations; very long ones delay failure detection. Choose a setting that reflects how stable your network is.
fallback checks whether members are available and picks an available option in candidate order, making it suitable for primary/backup setups; it doesn't mean “use whichever is fastest.” load-balance distributes connections across members, but won't split a single download across outbounds to make it faster. Sites that require session continuity may treat consecutive requests from different outbounds as a change in environment. For these cases, prefer a fixed member or a dedicated rule group.
Probe results show how an outbound performs when accessing the probe URL. They don't directly predict download bandwidth or long-connection stability, and they don't prove that a target service is reachable. If the probe host can't resolve, several otherwise working members may all be marked unavailable. If the probe succeeds but the service fails, the group type doesn't have to be the first suspect. Start a new connection to the actual service and compare it with the probe result.
Check where members come from and which outbound a connection uses
Groups that use a provider get their members with use. Providers have their own health-check settings and can share a source across groups; group test parameters describe that group's selection task. Before testing a group, confirm its member list isn't empty. If filtering removes every proxy, changing the probe interval won't bring them back. First check whether the source loaded, then verify which names the filter expression matches.
When debugging nested groups, start with a rule you know has matched. Check whether it hands off to the primary group, whether that group selects a manual proxy or an automatic group, and finally which outbound the connection actually uses. An automatic group highlighted in the interface doesn't mean every connection goes through it; a rule may send requests to another group. Conversely, a connection that's already established won't move to a new outbound just because you changed a group member in the UI.
To persist group selections, set store-selected: true under profile so the core saves them. If the selected member after startup differs from the order in the file, check whether a previous selection was restored or synchronized by the client. Don't rely on reordering the member list as the only way to reset runtime state. Select a member explicitly in the panel, then confirm the behavior with a new connection.
Before renaming configuration entries, list every dependency: group members, rule targets, and any client selection that may store the old name. After the change, test the configuration and send two separate requests to the same domain: the first to verify manual selection, the second to verify automatic selection. If only automatic mode fails, check the probe URL and candidate members rather than deleting the manual proxy that already works.
When you have many candidates, separate groups with stable purposes from temporary test groups. For example, have everyday rules use an approved primary group, then add new sources to a separate selection group and test them with a limited set of rules. You can remove a test source without touching everyday rules, while keeping the original outbound for comparison. For switching groups and checking the exit route, see First connection and outbound verification guide.
Rule syntax, order, and rulesets
Interpret results by the first matching rule
rules is a list evaluated from top to bottom. In rule mode, a connection uses the outbound specified by the first matching rule. Most entries have three parts—type, condition, and target—separated by commas. MATCH has no condition and goes straight to the target, so put it last. If a broad suffix rule comes first, more specific exceptions below it won't match unless you change the order.
rules:
- DOMAIN,api.example.com,PROXY
- DOMAIN-SUFFIX,example.com,DIRECT
- IP-CIDR,192.168.50.0/24,DIRECT,no-resolve
- MATCH,PROXY
In this example, the exact hostname api.example.com matches the first rule; other names matching the suffix go direct. DOMAIN-SUFFIX matches on domain boundaries, not an arbitrary substring. A rule target can be a defined group name, proxy name, or built-in outbound such as DIRECT or REJECT. Don't use a mode name as a rule target: rule mode describes the overall routing strategy, while the rule's target specifies where this connection goes.
| Type | Matches | Limitations |
|---|---|---|
DOMAIN | Exact domain | Excludes protocol, port, and path |
DOMAIN-SUFFIX | A domain and its subdomains | Put exception domains before the general suffix rule |
IP-CIDR | Destination IPv4 range | Use IP-CIDR6 for IPv6 |
RULE-SET | Contents of a registered ruleset | Still follows first-match priority |
MATCH | Connections not matched by earlier rules | Place after all active rules |
An address-range rule may need to resolve a domain to an address before it can compare. Adding no-resolve prevents the rule from triggering resolution for the comparison, but an existing destination address can still match. This can reduce extra lookups for traffic matched by a known address. If you expect a domain to resolve to an internal address and match the rule, this option may cause it to be skipped. Before using it, confirm what input will be available to match.
Move long rule lists into a provider
rule-providers registers a separate rules source; RULE-SET specifies where to use it in the main list and which outbound to select. The source's behavior determines how entries are interpreted. Use domain and IP-CIDR behaviors for their respective collections; classical can hold entries with rule types. The example uses a YAML file in the working directory. The entries don't specify an outbound; the rule that references the collection does that once for the whole set.
rule-providers:
project-sites:
type: file
behavior: classical
format: yaml
path: ./project-sites.yaml
rules:
- DOMAIN,api.example.com,PROXY
- RULE-SET,project-sites,DIRECT
- MATCH,PROXY
payload:
- DOMAIN-SUFFIX,example.com
A ruleset's position in the list works like a combined condition; it doesn't get higher priority just because it comes from an external file. If a site's outbound changes after an update, first check which ruleset matched, then see whether it added an entry that covers the site. Looking at just a handful of rules in the main file won't reveal the full scope of a collection. Treat provider load failures separately from a successfully loaded collection that simply didn't match.
Reproduce a connection and find the first matching rule
First note the destination used for matching in the logs and confirm whether it's a hostname or an address. Then identify the match type, matched value, and outbound path. A webpage often connects to several domains; the main page using the expected outbound doesn't mean its images, login API, and static assets use the same route. Fix only the failed request's destination. Narrow exceptions are easier to verify than routing an entire broad domain or address range through one policy.
Test with a new connection to exactly the same destination to avoid browser cache and existing connections. Before editing, write down three expected results: a specific exception, a general ruleset match, and a request that falls through to the catch-all. Check all three after the change, not just the domain you fixed. If rules seem to have no effect, check the operating mode first, then see whether an override layer moved the new rule below the catch-all.
Don't treat domain rules as a substitute for access control. An app that connects directly to an address, uses a different hostname, or bypasses interception may never provide the input your rule expects. Environments with mandatory policies should enforce them at the appropriate network control point. This part of the configuration explains how a connection that has entered the core is routed; it doesn't guarantee that every app is subject to the same rules.
TUN interception, system routes, and DNS hijacking
First decide whether the app needs a lower-level entry point
System proxy settings depend on apps choosing to use the operating system's settings or specifying an HTTP or SOCKS address themselves. TUN uses a virtual network interface to send traffic matching route conditions into the core. If a browser already follows the system proxy and works, you may not need TUN. Consider configuring the virtual adapter, routes, and required permissions only if an app ignores the system proxy or you need to test a different traffic entry point.
tun.enable enables the interface; stack selects the network stack for processing traffic; auto-route asks the core to configure the routes needed for interception; and auto-detect-interface detects the default outbound interface. The snippet below is for a single-machine test on platforms that support these fields, not a universal cross-platform setup. Before making changes, record the current network interfaces and default route so you can confirm the client has reverted them afterward.
tun:
enable: true
stack: mixed
auto-route: true
auto-detect-interface: true
dns-hijack:
- any:53
- tcp://any:53
dns-hijack sends matching plaintext DNS requests to the core's DNS module and is usually used with dns enabled. The example covers UDP and TCP queries sent to the standard port, but doesn't turn an app's encrypted DNS connection into a plaintext query the core can inspect. Enabling route interception without checking the query path can let connections reach the core while hiding the hostname the app originally looked up.
Check the interface first, then routes and connections
A desktop client showing that TUN is enabled doesn't prove the system created the interface. Check the client logs for permission, driver, or interface initialization errors. If the interface exists, check whether the default traffic or destination subnet uses it. The client determines how permissions and drivers are prepared on each operating system. Choose a platform on the client download page; desktop and mobile users can check the Clash Plus option where available, while Linux users should choose a client or core listed for that platform.
Port values in the configuration, interface names in the system, and the routing table are three different things to check. A process can accept requests on its local mixed port while failing to create a virtual interface. First establish a known-good baseline with an explicit proxy request. Then disable the app's manual proxy and test an app that normally ignores the system proxy. This lets you compare both entry points with the same destination instead of conflating an interface problem with a proxy problem.
When running a corporate VPN, another virtual adapter, or a container bridge, watch for overlapping subnets and competing default routes. Auto-detection works best when the outbound path is clear; with multiple paths, check which one it selected. For example, if an internal address stops working after connecting to a VPN, check route priority and whether DNS still reaches corporate services. Adding a direct rule at the end won't fix an incorrect system route.
ip link show
ip route show
ip route get 1.1.1.1
ip -6 route show
These Linux commands inspect the current state without changing routes. In policy routing setups, the main routing table may not show every decision; if needed, check ip rule show and the relevant routing tables. Rerun the lookup for a known failing destination to get more useful evidence than the default route alone. For server work directories and service startup, see Deploy mihomo on Linux with the command line and systemd.
Handle partial failures and preserve a way to roll back
If only some requests fail, first determine whether the issue affects a specific subnet, protocol, or IPv6 connections only. If small requests work but larger transfers stall, consider MTU as a factor and adjust it based on evidence from the actual link and route. Don't change the stack, MTU, and DNS mode all at once. After each change, repeat the same request to the same destination.
After disabling TUN, check that system routes, DNS, and the system proxy have returned to the expected state, especially on a remotely managed machine. Changing the default route remotely can disconnect your current session, so prepare a local console or a separate management path first. If an app still behaves differently, check for an app-level proxy or existing connections; disabling interception in the client doesn't clear settings saved by other programs. For platform-specific symptoms, see Troubleshooting in the FAQ.
Some issues appear only after changing networks, such as switching from wired to wireless or reconnecting after sleep: the outbound address and gateway may have changed. During retesting, note the default interface before and after the switch, confirm whether the new connection uses the new route, and compare access to LAN resources with access to external sites. Restarting the browser might change the result temporarily, but it doesn't prove that interface detection and route recovery are complete.
Overrides, merging, and validating changes
Distinguish what the core reads from what the client generates
The core reads the final configuration. The filename override.yaml doesn't make the core load it automatically, and clients don't necessarily support the same override methods. Treat the remote subscription as the upstream source and put your own rules and parameters in a local layer that can be reapplied. When updating, follow the client's instructions to generate a new result, then inspect the effective configuration so personal settings aren't left in a copy that gets replaced on refresh.
“Merging” can mean at least three things. Scalars are usually replaced directly, such as a port value. Mappings may merge recursively by child key or be replaced as a whole; for example, whether a snippet containing only dns.enable preserves the existing upstreams depends on the tool. Lists especially need careful checking: they may be replaced, prepended, or appended. YAML represents data structure; it doesn't tell the client which of these operations to perform. If the behavior isn't documented, test the result before applying it.
This example shows two intended changes in an override layer: change the mixed port and specify a general DNS upstream. If the tool merges mappings recursively, the existing DNS listener setting may be preserved; if it replaces the whole block, fields omitted from the snippet won't carry over. For testing, choose a non-default field from the old block and check whether it appears in the final file. That's a better way to identify the merge behavior than checking only whether the new upstream appears.
mixed-port: 7895
dns:
enable: true
nameserver:
- https://dns.alidns.com/dns-query
Check where rules are inserted when merging lists
When adding a domain exception, you usually need to place it before the broad rule that already covers that domain. The example shows the final snippet after the change, not a merge instruction for any particular client. The result makes three things clear: the exception comes first, the rule covering the whole domain follows, and the catch-all remains last. If the tool can only append to the end of a list, it can't put the exception in the right position.
rules:
- DOMAIN,api.example.com,DIRECT
- DOMAIN-SUFFIX,example.com,PROXY
- MATCH,PROXY
Don't guess how lists merge based on the shape of their entries. Two proxy definitions may both contain name, but the tool may not update them in place by name; concatenating them can create duplicates or leave groups referencing old names. Rule lists have positional semantics, while proxy lists are mainly referenced by name, so they shouldn't share the same deduplication assumptions. If an override renames a proxy, check all rules, groups, and locally saved selections too.
Remote updates often expose hidden dependencies on upstream names and ordering. If a local rule targets a group provided upstream, renaming that group can make the rule fail to find its target. One option is to define a local group with a stable name and clear purpose in the final configuration, then have it reference the available sources. When upstream content changes, update the group's members and sources without changing the target used by the rules.
Validate changes by reviewing the diff, loading the config, and testing it at runtime
Keep the previous working configuration so you can roll back immediately. If the client can export the final configuration, save both versions in a test directory and compare them before checking syntax. The filenames in the example refer to those exported files; the working directory should also contain their local dependencies. A diff tool reporting changes doesn't mean the command failed. Focus on whether added keys, removed entries, and reordered lists match your expectations.
diff -u previous.yaml effective.yaml
mihomo -t -d "$PWD" -f "$PWD/effective.yaml"
If the diff is larger than expected, check first whether a list was replaced wholesale or shared settings were reapplied by the client. If both files look correct but fail validation, confirm that the test core loads the right file from the same working directory and can find its required resources. Don't delete entire providers or rule sections just to get a passing check; that would mean you're validating a different configuration.
After loading, test only the paths affected by this change. For a port change, confirm the new listener accepts connections and update any apps still pointing to the old port. For DNS, query one name matching a policy and another using the default upstream. For rules, test an exception, a general rule, and the catch-all. If you can't reproduce every use case on site, restore the working configuration and replay them individually against a test copy instead of making several changes to the live file.
Finally, test a subscription refresh. A static check proves only that the current file can be read; the diff after a refresh shows whether local changes persist. Confirm that local rule placement, group members, and ports still match expectations, and check whether previously selected members were restored. If the refresh causes a problem, save the upstream changes and local merge result separately. That makes it easier to trace the diff next time instead of guessing through the entire traffic flow again.
When rolling back, check in order from entry point to outbound: switch to the old configuration, confirm the client loaded the old file, then restore any related system settings you changed. Switching files alone doesn't complete the rollback if another process still occupies the old port. Keep a local record of each change, its test target, and the result. When changing the same section again, those test notes are more useful than a bare “it works.”