#2064·Marzban

Clash subscription generates invalid IPv6 server address with square brackets

Author: cher9lieCreated Jun 5, 2026Updated Jun 5, 2026

Describe the bug

When using {SERVER_IPV6} as the host address in Marzban panel, the generated Clash/Clash Meta subscription wraps the IPv6 address in square brackets, causing connection timeout in Clash-based clients (e.g. FlClash, Clash Meta).

Generated (broken):

yaml
server: "[2603:c020:1d:xxxx:x:xxxx:xxxx:xxxx]"

Expected (correct):

yaml
server: "2603:c020:1d:xxxx:x:xxxx:xxxx:xxxx"

Manually removing the brackets from the server field fixes the issue immediately.

To Reproduce

  1. Go to Marzban panel → Host settings
  2. Set a VLESS Reality inbound's address to {SERVER_IPV6}
  3. Save and update subscription in a Clash-based client (FlClash / Clash Meta)
  4. The IPv6 node shows Timeout
  5. Export the Clash config YAML, observe server: "[2603:xxxx]" with brackets
  6. Remove brackets manually → node connects successfully

Expected behavior

The server field in generated Clash YAML should contain the raw IPv6 address without square brackets, since server and port are separate fields in Clash config format.

Screenshots

N/A (reproducible via config file inspection)

Machine details:

  • OS: Ubuntu 24.04 (Oracle Cloud ARM)
  • Marzban: Docker deployment
  • Client: FlClash (Clash Meta core)
  • Browser: Chrome

Additional context

Root cause traced through source code:

  1. In app/utils/system.py, get_public_ipv6() returns IPv6 wrapped in brackets (return '[%s]' % resp). This is correct for URI formats like vless://uuid@[ipv6]:port.

  2. In app/subscription/share.py, this value is stored as SERVER_IPV6 and passed through setup_format_variables()process_inbounds_and_tags()conf.add(address=...).

  3. In app/subscription/clash.py, make_node() assigns server = address directly without stripping brackets:

python
node = {
    'name': remark,
    'type': type,
    'server': server,    # bracketed IPv6 written as-is
    'port': port,
    ...
}

Suggested fix in app/subscription/clash.py, make_node():

python
node = {
    'name': remark,
    'type': type,
    'server': server.strip('[]'),
    'port': port,
    'network': network,
    'udp': udp
}

singbox.py may have the same issue and should also be checked.