Clash subscription generates invalid IPv6 server address with square brackets
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):
server: "[2603:c020:1d:xxxx:x:xxxx:xxxx:xxxx]"Expected (correct):
server: "2603:c020:1d:xxxx:x:xxxx:xxxx:xxxx"Manually removing the brackets from the server field fixes the issue immediately.
To Reproduce
- Go to Marzban panel → Host settings
- Set a VLESS Reality inbound's address to
{SERVER_IPV6} - Save and update subscription in a Clash-based client (FlClash / Clash Meta)
- The IPv6 node shows Timeout
- Export the Clash config YAML, observe
server: "[2603:xxxx]"with brackets - 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:
In
app/utils/system.py,get_public_ipv6()returns IPv6 wrapped in brackets (return '[%s]' % resp). This is correct for URI formats likevless://uuid@[ipv6]:port.In
app/subscription/share.py, this value is stored asSERVER_IPV6and passed throughsetup_format_variables()→process_inbounds_and_tags()→conf.add(address=...).In
app/subscription/clash.py,make_node()assignsserver = addressdirectly without stripping brackets:
node = {
'name': remark,
'type': type,
'server': server, # bracketed IPv6 written as-is
'port': port,
...
}Suggested fix in app/subscription/clash.py, make_node():
node = {
'name': remark,
'type': type,
'server': server.strip('[]'),
'port': port,
'network': network,
'udp': udp
}
singbox.pymay have the same issue and should also be checked.
Source: Gozargah/Marzban