port, socks-port, and mixed-port: How apps connect

Start with the top-level ports. port is the HTTP proxy listener and can also handle HTTPS connections via CONNECT. socks-port is the SOCKS proxy listener, while mixed-port accepts both HTTP and SOCKS connections on the same port. The example below uses 7890 as a local mixed port; not every client uses this value.

mixed-port: 7890
allow-lan: false
mode: rule
log-level: info

If an app asks for an HTTP proxy, enter host 127.0.0.1 and port 7890 in this example. If it requires SOCKS5, select the correct proxy type in the app. Typically, use one mixed port or separate ports for each protocol; do not set port and mixed-port to the same port.

  • Use allow-lan: false for local-only access. If a port is unreachable, first check the listening address and port in the startup logs, then see whether another client instance is using it.
  • mode: rule routes traffic according to rules. If the client UI is set to Global or Direct mode, rule matches cannot tell you whether the YAML is correct.
  • external-controller is the listening address for the control API, not an app proxy endpoint. For example, a local UI can connect to 127.0.0.1:9090, but this is not a port to enter in your browser's proxy settings.

dns: Separating the listener, upstreams, and returned addresses

dns.enable turns on the core's DNS module; dns.listen sets the address where it listens for DNS requests. They are separate settings. Configuring a listener does not change the operating system's DNS servers. Whether requests reach the core depends on the app's resolution method and how its traffic is routed.

dns:
  enable: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  nameserver:
    - 223.5.5.5

223.5.5.5 is an example of a plain DNS upstream; choose one based on your network and trust requirements. nameserver configures upstreams for regular queries. Fake-IP controls how the core responds to eligible lookups: it can return a mapped address from the configured range, then recover the domain when handling traffic to that address. Seeing a mapped address in the 198.18.0.0/16 range in connection logs does not mean the destination server is on that network.

What if Fake-IP responses affect LAN services?

If a device-management app needs the real address, note the exact hostname it queries and confirm that its DNS requests go through the core. For mihomo's default blacklist-style filtering, add hostnames that need real addresses to dns.fake-ip-filter. This only changes how those queries are answered. If the upstream cannot resolve an internal hostname, configure a resolver that can. Another common option, redir-host, uses real resolved addresses instead of assigning Fake-IPs; switching to it will not fix an unreachable upstream.

Which resolver looks up proxy server hostnames?

If a node's server is a hostname, it must be resolved before the connection can start. In mihomo, proxy-server-nameserver lets you specify a resolver for proxy server hostnames. If hostname-based nodes fail while IP-based nodes still connect, check this first. Make sure the upstream needed to resolve a node hostname does not itself depend on that same, not-yet-connected node. Older Clash branches may not support every mihomo DNS field, so check against the core you are actually running.

proxies: Reading a node's connection settings

proxies is a list, with each node entry starting with a hyphen. The example below shows the structure using a local HTTP test upstream. Use this address only if a separate local service is listening for HTTP proxy requests on 18080; do not point it back to the current configuration's 7890 listener.

proxies:
  - name: Local-HTTP
    type: http
    server: 127.0.0.1
    port: 18080
  • name is the identifier used by rules and groups. After changing it, check all references so groups do not still point to the old name. Avoid duplicate names across nodes, groups, and built-in policies.
  • type determines which protocol is used to establish the connection and which other fields are required. When switching protocols, configure the appropriate credentials and transport settings; changing only type does not make the remaining fields interchangeable.
  • The entry's port: 18080 is the upstream port to connect to. The top-level mixed-port: 7890 is the local port where the core waits for app connections—the two serve opposite purposes.

Subscriptions do not always list every node directly under the top-level proxies key. Some configurations define node sources in proxy-providers, which policy groups reference by provider name through use. A node missing from the top-level list is not necessarily missing from the configuration. When troubleshooting updates, distinguish the subscription source, provider cache, and configuration actually loaded by the client. Direct edits to generated files may be overwritten on the next update.

proxy-groups: Separating rule targets from node selection

A policy group gives rules a stable target name. The Route group below lists Local-HTTP and the built-in policy DIRECT. Once rules point to Route, you can switch its selected member in the UI without editing every rule that references the group.

proxy-groups:
  - name: Route
    type: select
    proxies:
      - Local-HTTP
      - DIRECT
Group typeHow it selectsWhat to check in the config
selectChoose a member manuallyCurrent UI selection; the saved choice may be restored after restart
url-testSelects based on probe results, subject to settings such as toleranceurl, interval, and tolerance
fallbackSelects the first available member in the groupMember order and health check results

For url-test, interval: 300 sets the probe interval to 300 seconds. tolerance: 50 is measured in milliseconds and helps avoid switching due to small latency changes. Probe results reflect performance when accessing the specified URL, not download throughput. If a rule matches the right group but traffic exits through the wrong node, check the group's current selection or built-in policy before adjusting probe settings.

rules: From the first match to the fallback policy

In Rule mode, the core evaluates rules in list order. Most lines can be read as “match type, match value, policy target,” but MATCH needs no match value. It catches connections that did not match earlier rules, so it usually belongs at the end. The order of top-level fields mainly affects readability; the order within the rules list changes how traffic is handled.

rules:
  - DOMAIN,api.example.com,DIRECT
  - DOMAIN-SUFFIX,example.com,Route
  - IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
  - MATCH,DIRECT
  1. If the destination hostname seen by the core is api.example.com, the first rule sends it to DIRECT. Move the suffix rule above it and the hostname will match that rule instead; the outcome then depends on the current selection in Route.
  2. IP-CIDR matches a network based on the destination IP. no-resolve prevents this rule from triggering a DNS lookup just to evaluate the match; it can still match when the destination IP is already known. It does not disable DNS globally.
  3. MATCH,DIRECT explicitly sets the fallback policy. Changing it to MATCH,Route changes the exit path for all traffic not matched by earlier rules. Add new rules before the fallback line.

Domain rules require the core to know the destination hostname. If an app resolves the name itself and submits only the destination IP, the core may not see the original hostname unless an existing Fake-IP mapping, sniffing, or another mechanism can recover it. When troubleshooting, check the destination, matched rule, and policy chain in the UI's connection log or in the logs. Do not infer the match from the hostname in the browser's address bar alone.

How to validate changes to config.yaml

First confirm which configuration the client loads and which core it runs. The active configuration may be generated by merging a subscription with overrides, or affected by the client's runtime settings. If you use the standalone mihomo executable, run mihomo -v to check its version, then test the configuration you intend to load:

mihomo -t -f ./config.yaml
  1. Check syntax first. Indent with spaces, not tabs. Keep only one copy of each key at the same mapping level, and do not add another top-level rules: just to append rules. Quote node names containing # or a colon followed by a space so YAML does not mistake them for comments or mappings.
  2. Then check references. Starting from the last policy field in a rule, trace it back: if it is Route, find the group with that name under proxy-groups, then check whether its members come from proxies, a provider, another group, or a built-in policy. Treat no-resolve as an optional parameter; the policy name comes before it.
  3. Finally, check runtime behavior. A successful config test does not guarantee that ports can bind, DNS upstreams are reachable, or nodes can connect. After loading the config, use an app through the configured entry point to make one connection that should match an earlier rule and another that should hit the fallback. If no new connection appears in the logs, check the entry point first. If the match is correct but the connection fails, check group selection, DNS, and the upstream.

For subscription-generated configurations, save local changes through the client's supported override or merge settings whenever possible. Before sharing logs, remove any node credentials or subscription URLs. This preserves reproducible troubleshooting steps instead of a temporary file that may stop working after the next subscription update.