V2Ray Config File Explained: A field-by-field guide to inbounds, outbounds, and routing

Explore a complete V2Ray config example, with clear explanations of log, inbounds, outbounds, routing, and tag references in client-generated configs.

At a glance

Start with the inbound port your app connects to, then check routing rules in order, and finally find the outbound with the matching tag. The examples below let you reproduce direct connections and blocking locally, distinguish a wrong port from a rule that didn’t match or an outbound connection failure, and show where to change settings when a client regenerates its config.

Complete example: Two inbounds and two outbounds

This config uses a common V2Ray JSON structure. It listens only on loopback and provides SOCKS and HTTP inbounds. Requests to blocked.example are blocked; all others connect directly. The example needs no remote servers, subscriptions, or geolocation rule files, so you can run it on its own and see how the config works. It does not automatically route system traffic through the core; only apps explicitly configured to connect to these two ports use this routing chain.

App requestLocal inboundRouting matchSelected outboundDirect or blocked
{
  "log": {
    "loglevel": "warning"
  },
  "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": "block",
      "protocol": "blackhole",
      "settings": {}
    }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "domain": ["full:blocked.example"],
        "outboundTag": "block"
      },
      {
        "type": "field",
        "inboundTag": ["socks-in"],
        "outboundTag": "direct"
      }
    ]
  }
}

At the top level, log and routing are objects, while inbounds and outbounds are arrays. Don’t mistake routing.rules for a single object, and remove comments and trailing commas before copying this into a production config. Array order matters: rules are checked in sequence, and if none match, the first outbound is used. Before reordering array items, make sure you won’t change either behavior.

log and inbounds: Log level, listening ports, and request entry points

10808
Example SOCKS inbound port
10809
Example HTTP inbound port

log.loglevel controls how much detail appears in the logs. This example uses warning to start with startup warnings. The absence of per-connection entries doesn’t mean traffic isn’t reaching the core. To reproduce an issue, temporarily switch to info, or use debug for more detail. Reload the config in the core after changing it. Restore the original level when you’re done, and remove internal addresses, domains, and credentials before sharing logs.

SOCKS inbound

listen
127.0.0.1
port
10808
protocol
socks
tag
socks-in

Authentication is not required in this example, and SOCKS UDP is disabled; tests use TCP.

HTTP inbound

listen
127.0.0.1
port
10809
protocol
http
tag
http-in

This is the local HTTP proxy endpoint that apps connect to, not a port on the destination website.

The app must use both the correct proxy type and port. Sending a SOCKS request to the HTTP inbound will fail during the proxy handshake, even if the TCP connection succeeds; changing routing rules won’t help. settings is interpreted according to protocol: auth and udp are SOCKS settings here, not options shared by both inbound types. The example ports aren’t fixed defaults. If a client is already using either port, stop the conflicting instance or update the ports in both the example and the test commands.

outbounds: Protocol determines behavior; tags let rules select an outbound

freedom connects to the destination address; blackhole drops requests instead of forwarding them. An outbound’s tag is an identifier in the config; it does not determine the protocol. Renaming a tag to direct won’t turn a proxy outbound into a direct connection. Likewise, changing a tag without updating its references won’t make existing rules point to the new name.

Rule fieldWhere to find itExample and purpose
inboundTaginbounds[].tag["socks-in"]: Match only requests received through the specified inbound.
outboundTagoutbounds[].tag"block": Send matching requests to the blocking outbound.

Client-generated configs may also include remote proxy outbounds, such as an entry with protocol set to vmess. Its connection parameters belong to that outbound and are separate from the local SOCKS listening port. To find where a request goes, get outboundTag from the matching rule, find the outbound with the same tag, and inspect its protocol, settings, and any streamSettings it actually has. Don’t infer the destination address, transport, or TLS status from a node label or tag name.

How to check: Find the outbound by its exact tag

When reviewing a generated config, check that every outboundTag has a corresponding outbound definition. If you change an outbound tag, update its references too, and check the first array entry separately so the paths for matched and unmatched requests don’t get confused.

routing: First match, default outbound, and domain strategy

Routing checks rules starting at rules[0]. Once a rule matches, its specified outbound is selected, and no more specific rules are considered. If a field rule includes both domain and inboundTag, the request must satisfy both conditions. The example uses separate rules for blocking a domain and sending SOCKS traffic directly so the block applies to requests from both inbounds.

  1. Any inbound request to blocked.example: The first rule uses full: for an exact domain match and sends the request to block. Subdomains are not included.
  2. Other requests from the SOCKS inbound: The first rule doesn’t match; the second matches on inboundTag and sends the request to direct.
  3. Other requests from the HTTP inbound: Neither rule matches, so outbounds[0] is used. In this example, the first outbound also happens to be direct, so the connection has the same result as in the previous case, but a different outbound was selected for a different reason.

If you move the SOCKS direct rule to the top, SOCKS requests to the blocked domain will match the direct rule first; HTTP requests will still match the domain rule. If the same domain behaves differently in two apps, check both the inbound tag and whether each app sends the domain name or an already-resolved IP address to the proxy.

Local testing and troubleshooting

Save the example as a separate config and have the core load it; don’t overwrite the file currently used by your client. Set up a controllable local target: open a terminal in an empty directory and run python -m http.server 18080 --bind 127.0.0.1. Open a second terminal and run the commands below. In Windows PowerShell, use curl.exe to call curl explicitly. The commands specify the proxy directly and clear curl’s proxy bypass list so environment settings won’t exclude loopback addresses from the test.

curl --noproxy "" --max-time 5 --socks5-hostname 127.0.0.1:10808 http://127.0.0.1:18080/
curl --noproxy "" --max-time 5 --proxy http://127.0.0.1:10809 http://127.0.0.1:18080/
curl --noproxy "" --max-time 5 --socks5-hostname 127.0.0.1:10808 http://blocked.example/

The first two commands should receive HTTP responses from the local server, and its terminal should show two requests. The last command uses --socks5-hostname to send the domain to the proxy instead of resolving it locally with curl. It is expected not to retrieve the destination page. This failure alone doesn’t prove the rule matched: the reserved domain could fail to resolve even over a direct connection. Check the core’s runtime logs to confirm which outbound was selected. Stop the temporary HTTP server when you’re done testing.

  1. Proxy port refuses the connection: First check whether the core loaded the JSON successfully, then verify listen and port. If the logs say the port is already in use, don’t mistake a response from another instance for the result of this config.
  2. Port connects, but the request fails: Make sure the proxy protocol matches the inbound type, then check the destination address and the first rule whose conditions are actually met. If a domain rule doesn’t match, check whether the app is sending only the resolved IP to the proxy.
  3. Correct outbound selected, but destination is unreachable: Check the destination service’s listening address, port, and connection errors. A direct match only means the core selected the direct route; it doesn’t guarantee the destination can receive the request.
  4. Changes disappear after restarting the client: Check whether you edited a runtime-generated file or a setting the client actually saves. In v2rayN, for example, check local listener settings under Settings → Parameter Settings; available options vary by version and core. To keep changes, save them in the corresponding client settings or in a separate config that you maintain and explicitly load.

V2Ray Client Downloads and Setup Guides

Choose a client for your operating system, then follow the guide to check the local proxy port and how to connect your apps.

Client downloads