At a glance

For anyone with a JSON export from v2rayN who isn't sure where to start. Find the inbound by its local port, then follow the requested destination and the rules' outboundTag to identify the outbound. Finally, check where DNS resolution happens. You'll be able to tell apart an inbound connection problem, a rule selecting the wrong outbound, and an outbound connection failure.

A V2Ray JSON Config Example: Trace a Connection

An inbound is where the core accepts an application connection; an outbound is how it handles that connection; routing links the two by choosing an outbound for each request. DNS resolves domain names to IP addresses, but the core doesn't resolve every connection. Don't read the JSON top to bottom as a sequence of commands. Start with the inbound receiving the request, check the routing rules, then look up the selected outbound.

App connectionInbound receives itDestination identifiedRouting rule matchedOutbound handles it

This example uses the traditional JSON format supported by V2Fly V2Ray 5.x. It has two local inbounds and three outbounds. The proxy server uses the documentation-only address 192.0.2.10, and the UUID is for demonstration; the config illustrates the structure but does not connect to a working proxy service. Configs loaded by Xray often use similar fields, but always check the core and version actually in use.

{
  "log": {
    "loglevel": "info"
  },
  "inbounds": [
    {
      "tag": "socks-in",
      "listen": "127.0.0.1",
      "port": 10808,
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    },
    {
      "tag": "http-in",
      "listen": "127.0.0.1",
      "port": 10809,
      "protocol": "http",
      "settings": {}
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {}
    },
    {
      "tag": "proxy",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "192.0.2.10",
            "port": 443,
            "users": [
              {
                "id": "11111111-1111-4111-8111-111111111111",
                "alterId": 0,
                "security": "auto"
              }
            ]
          }
        ]
      }
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {}
    }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "domain": ["full:blocked.example.net"],
        "outboundTag": "block"
      },
      {
        "type": "field",
        "domain": ["domain:example.net"],
        "outboundTag": "proxy"
      },
      {
        "type": "field",
        "ip": ["127.0.0.0/8", "::1/128"],
        "outboundTag": "direct"
      }
    ]
  },
  "dns": {
    "servers": ["localhost"]
  }
}

V2Ray Inbounds: Which Port Does the App Connect To?

listen is the address the core binds to on the local machine, port is where the app connects, and protocol specifies the proxy protocol used by the inbound. In this example, 127.0.0.1 is the IPv4 loopback address, so connections stay on the local machine; it has nothing to do with the remote server address. tag names the inbound but doesn't affect listening or determine the proxy type. Routing rules can refer to it with inboundTag.

SOCKS inbound

Tag
socks-in
Listen address
127.0.0.1
Listen port
10808
UDP
false

Set the app to SOCKS5. This example is for testing TCP connections only, not UDP.

HTTP inbound

Tag
http-in
Listen address
127.0.0.1
Listen port
10809
Tunnel mode
CONNECT

Set the app to use an HTTP proxy. HTTPS sites can also use this inbound; HTTP CONNECT establishes the tunnel.

To check v2rayN, open Settings → Parameter Settings and review the local listening options, then compare them with listen and port in the active config. Option names can vary by version. If the app reports a connection refusal, first check that the core is running and that its logs don't report a port conflict. Then make sure the app's protocol and port match the inbound. If you change only the inbound port without updating the app settings, the app will keep connecting to the old port—and routing won't come into play.

V2Ray Outbounds: Tags, Servers, and Destinations

In this example, proxy is just a referenceable name; the actual protocol is VMess, specified by protocol. The address and port under settings.vnext are the proxy server's address and port. They are not the website the browser is visiting or the local port the app connects to.

When reading an exported config, don't assume that port 443 means the connection uses TLS. Check the outbound's streamSettings: the transport and transport security are separate settings, and both must match the server. This example omits those settings and does not enable TLS. If the exported protocol is VLESS, don't reuse the VMess user fields from this example. Look up the config structure for that protocol and core.

V2Ray Routing Rules: Predict the Outbound in Order

routing.rules are checked from top to bottom. The first matching rule selects its outboundTag; later, potentially more specific rules aren't checked. full: matches an exact domain, while domain: matches that domain and its subdomains. The examples below assume the inbound receives the listed destination as-is, without considering an app that resolves the domain beforehand.

Outbounds inferred from the sample rules—not a connectivity test
Destination received by the coreFirst matching conditionOutbound tag
blocked.example.netRule 1: exact domainblock
www.example.netRule 2: domain and subdomainsproxy
127.0.0.1:18080Rule 3: loopback IP rangedirect
example.orgNo match; use the first outbounddirect

Takeaway: Check for an earlier rule match

To block a specific subdomain, place its full: rule before the broader domain: rule that also matches it. When troubleshooting, compare the destination against both rules. Don't reorder the entire outbound array to fix one exception; that would also change the default outbound for unmatched requests.

The 18080 shown in the table is the destination server's port, not a routing condition: the third sample rule matches only the destination IP. If a rule specifies both ip and port, both conditions must match. To match either an IP range or a port, create two separate rules. After editing, verify that outboundTag exactly matches an outbound tag. A missing tag does not mean traffic will default to direct.

V2Ray DNS and domainStrategy: When Is a Domain Resolved to an IP?

Here, dns.servers specifies how the core's built-in DNS resolves names; localhost means to use the system resolver. This doesn't register a DNS service with the system or automatically route every app's DNS query through the core. The sample uses AsIs for routing, meaning it won't resolve domains to IPs just to match IP-based rules. Outbounds such as direct can still resolve domains when establishing connections, according to their own settings.

Troubleshooting V2Ray Configs: From Startup Logs to Individual Requests

Troubleshoot with a reproducible request, changing one thing at a time. In a single row, record the inbound used by the app, the destination sent through the proxy, the expected matching rule, and the outbound tag shown in the logs. What the logs show depends on the core, log level, and access log settings. If the current level doesn't reveal the error, increase verbosity only while troubleshooting, then restore it.

The JSON looks valid. Why does the core exit on startup?

Start with the earliest error in the logs. If it says binding to 127.0.0.1:10808 failed, check whether another core is already listening. If it points to a protocol or field, verify the core and version, then compare against the original export. Don't delete the routing section first; these startup errors usually aren't fixed by changing routing.

Why does the same domain use a different rule in another app?

First confirm that both apps connect to the core, then check whether each sends a domain or an IP address. You can test the sample SOCKS inbound with this expected-to-fail request: curl --socks5-hostname 127.0.0.1:10808 http://blocked.example.net/. This option passes the domain to the SOCKS proxy, so the sample should select block. Don't treat a failed request alone as proof the rule matched; check the outbound recorded in the access or routing logs.

Why does my edited export revert after restarting?

First confirm which file the core loads at startup. An exported copy usually doesn't replace the runtime config the client regenerates from its current node and settings. To change the local port, go to Settings → Parameter Settings, make and apply the change, then check the new runtime config. For a custom config, make sure the client has selected that copy, then restart the core to verify it.