First, identify which database your rules use
GEOSITE matches domains by category; GEOIP matches destination IP addresses. If a site uses the wrong policy, start by checking the matched rule in the connection log. For a GEOSITE match, check the domain and category. For a GEOIP match, check the destination IP and the data format in use. Updating a different file usually won't change the result for that connection.
| Data file | Matches | When it's used |
|---|---|---|
GeoSite.dat | Domain categories | Read by GEOSITE rules; unaffected by geodata-mode |
GeoIP.dat | IP address ranges | Used by GEOIP when geodata-mode: true |
country.mmdb | Country and region data for IP addresses | Used by GEOIP when geodata-mode: false |
Filenames in download URLs may use different capitalization from those in the core's working directory. When replacing a file manually, use the exact name found in the working directory, especially on Linux. GeoIP.dat and country.mmdb are different formats; changing the file extension won't convert one to the other. Even if both datasets match CN, don't assume they cover exactly the same IP ranges.
The data source also determines which category names are available. After switching sources, if a GEOSITE category in your configuration triggers an error, first check whether the new file includes that category. If the matched rule is actually a RULE-SET, check the corresponding rule-providers entry instead. That entry controls the rule set's source and update schedule; geox-url does not manage it.
Configure geox-url and automatic updates
These examples are for configurations using the mihomo 1.19 series core. Run mihomo -v to check a standalone core's version. For a GUI client, check which core is actually selected; the client version is not the same as the core version. Add these fields at the top level of the YAML, alongside rules. If these keys already exist, merge the settings into them rather than adding duplicate keys.
geodata-mode: true
geo-auto-update: true
geo-update-interval: 24
geox-url:
geoip: https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat
geosite: https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat
mmdb: https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country.mmdb
geo-auto-update: trueenables automatic updates for the core's geodata. Changinggeox-urlalone only changes the download source; it does not enable scheduled updates.geo-update-interval: 24is measured in hours. This is not a system task that runs at a fixed time each day. When the core isn't running, it won't download data in the background on behalf of the operating system.geoip,geosite, andmmdbeach point to a file in the corresponding format. This example enables GeoIP in DAT format. If your existing configuration uses MMDB and you only want to update the data, keepgeodata-mode: falseand don't switch formats at the same time.
Verify downloads, files on disk, and rule matches
Check the core's logs after applying the configuration and confirm its actual working directory. Don't rely only on whether a data URL opens in your browser. The browser and update process may have different network access; browser access doesn't prove the core can resolve the hostname, complete the request, or write to the directory.
- Find the working directory. For a standalone core, check the
-dstartup argument. In a GUI client, check the core startup details or the client's data-directory option. The installation, subscription, and core data directories may all be different. - Use the logs to pinpoint the failure. For DNS resolution failures, connection timeouts, or HTTP errors, check the data source URL and current network. For write failures, check the running account's permissions on the data directory. For read or parse errors, verify that the saved file is in the expected format and isn't an error page returned instead of the download.
- Check the file and whether it was loaded. Note the file's modification time before and after the update, then compare it with the update and configuration-loading logs. A changed modification time only confirms that the file on disk changed; it doesn't prove the current connection is using the new data.
- Test a new connection. Before updating, note the destination domain, visible destination IP, matched rule, and final policy. After the update, reload the configuration or restart the core as supported by your client. Then close the old connection, make a new request, and record the same four details. Don't compare against a connection that was already established before the update.
How to replace a database file manually if automatic updates fail
Back up the current configuration and the relevant data file first, then get a file in the same format from a trusted data source. Stop the core and replace only the file you're testing. Keep its actual filename and read permissions unchanged. After restarting, check the loading logs and create a new connection. If categories are missing, the file can't be read, or routing regresses, restore the backup and restart. During troubleshooting, avoid changing the subscription, DNS settings, and rule order at the same time; otherwise, it's hard to tell what caused the result.
Why is routing still wrong after the database update?
First, confirm the proxy mode is rule and that the traffic appears in mihomo's connection log. If there's no entry, check the system proxy or the traffic captured by TUN. If you're using global or direct mode, the current traffic can't be used to test the rule order below.
Check whether an earlier rule already matched
rules:
- GEOSITE,cn,DIRECT
- GEOIP,CN,DIRECT
- MATCH,PROXY
This is an example of rule order. Replace PROXY with a policy group in your configuration, or make sure a group with that name exists. The core checks rules from top to bottom and stops at the first match. If a domain rule or RULE-SET appears earlier in your actual configuration, it may catch the connection before the geolocation rule gets a chance to match. A MATCH result only means no earlier rule matched; it doesn't necessarily mean the database is outdated.
Separate domain categories, destination IPs, and DNS changes
- If only the destination IP is available and no domain is provided for matching,
GEOSITEcan't determine the domain category from the IP. Check whether the app connects directly to an IP address or the client didn't receive the original domain. - With a rule like
GEOIP,CN,DIRECT,no-resolve, mihomo won't resolve the domain just to evaluate the rule. It can still match by IP when a destination IP is already available. Don't mistakeno-resolvefor disabling DNS across the entire client. - The same domain may resolve to different IP addresses because of a CDN or changes in DNS routing. Before comparing two connections, check the actual destination IP. With
fake-ipenabled, the synthetic address shown to the app isn't the server's address, so it can't tell you which region the server is in.
If the rule order, domain, and destination IP are all the same, but the matched category changes only after replacing the data, narrow the cause down to the data version or source. If only one domain needs a fixed policy, add an exact DOMAIN rule before the geolocation rule and document why. There's no need to replace the entire database for a single exception.