[GH-ISSUE #3371] [Self-hosted][Xray] Container always publishes UDP/443, so Xray cannot be installed next to AmneziaWG (regression since #2903) #3233

Open
opened 2026-11-07 17:57:59 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @nordz0r on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3371

Summary

On a fresh self-hosted server, installing Xray after AmneziaWG fails, because the Xray container publishes UDP/443 in addition to TCP/443. AmneziaWG already listens on UDP/443, so docker run fails with bind: address already in use and the install aborts with ServerPortAlreadyAllocatedError ("Server port already used. Check for another software").

AWG on UDP/443 and Xray on TCP/443 on the same server is a normal setup, and it worked before 2026-08.

Regression

$ git log -L 7,8:client/server_scripts/xray/run_container.sh --oneline
d702dc0b fix: various fixes for Telemt, XRay (VLESS), Captcha (#2903)   <- adds the /udp line
d18423ee Feature/xray custom port (#965)                                <- tcp only
ba4237f1 Xray with Reality protocol (#494)                              <- tcp only

Current content (client/server_scripts/xray/run_container.sh):

sudo docker run -d \
--privileged \
--log-driver none \
--restart always \
--cap-add=NET_ADMIN \
-p $XRAY_SERVER_PORT:$XRAY_SERVER_PORT/tcp \
-p $XRAY_SERVER_PORT:$XRAY_SERVER_PORT/udp \   # <-- added in #2903
-v $CONTAINER_NAME-data:/opt/amnezia/xray \
--name $CONTAINER_NAME $CONTAINER_NAME

start.sh got a matching rule in the same commit:

iptables -A INPUT -p udp --dport $XRAY_SERVER_PORT -j ACCEPT

Before #2903 the container published TCP only (March 2024 to August 2026), so AWG (UDP/443) and Xray (TCP/443) coexisted without issues.

Why the UDP publish is unnecessary

The Xray server config generated by the client only listens on TCP. In client/core/models/protocols/xrayProtocolConfig.cpp, xrayEffective::network() returns tcp for the default raw transport (with reality/tls security), so the single VLESS inbound has streamSettings.network: "tcp". Nothing binds UDP/443 inside the container; the published UDP port only reserves host UDP/443 via docker-proxy and blocks AWG.

The MKCP transport (network: kcp) does use UDP, but it is not the default, and the container port mapping is unconditional - it does not depend on the selected transport.

Observed on a live server (2026-11-01)

$ docker inspect amnezia-xray | grep -A6 PortBindings
"PortBindings": {
  "443/tcp": [ { "HostIp": "", "HostPort": "443" } ],
  "443/udp": [ { "HostIp": "", "HostPort": "443" } ]   # <-- conflicts with AWG
}
$ docker ps
4dcff48fc457 amnezia-xray ... Up 2 minutes 0.0.0.0:443->443/tcp, 0.0.0.0:443->443/udp

Pre-flight check misses it too

InstallController::isServerPortBusy() (client/core/controllers/selfhosted/installController.cpp:881) checks only the protocol's defaultTransportProto, which is Tcp for Xray (protocolUtils.cpp:172). The client therefore reports the port as free, and the failure only surfaces at docker run; AWG already occupying UDP/443 is not detected.

Workaround

Recreate the container without the UDP mapping (the data volume, and therefore server.json and the keys, survives):

sudo docker stop amnezia-xray
sudo docker rm amnezia-xray
sudo docker run -d \
  --privileged \
  --log-driver none \
  --restart always \
  --cap-add=NET_ADMIN \
  -p 443:443/tcp \
  -v amnezia-xray-data:/opt/amnezia/xray \
  --name amnezia-xray amnezia-xray
sudo docker network connect amnezia-dns-net amnezia-xray

Suggested fix

  1. Remove -p $XRAY_SERVER_PORT:$XRAY_SERVER_PORT/udp from client/server_scripts/xray/run_container.sh and the matching iptables ... -p udp --dport $XRAY_SERVER_PORT rule from start.sh.
  2. If UDP must stay for the MKCP transport, publish it conditionally on the selected transport instead of always (adding the iptables rule only in that case).
  3. Optionally, make isServerPortBusy() check the protocols the container will actually publish, so the conflict is reported before container creation.

Environment

  • AmneziaVPN client 5.0.3.0; the server scripts are identical in current dev (HEAD 7f9b7db4)
  • Server: Debian, Docker with the AmneziaWG kernel module loaded (lsmod | grep amneziawg -> amneziawg, libcurve25519)
  • Xray image: amnezia-xray, built from XRAY_RELEASE=v26.7.28
  • Reproduced on a fresh server: AWG installed first, Xray second
Originally created by @nordz0r on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3371 ### Summary On a fresh self-hosted server, installing **Xray** after **AmneziaWG** fails, because the Xray container publishes **UDP/443** in addition to **TCP/443**. AmneziaWG already listens on UDP/443, so `docker run` fails with `bind: address already in use` and the install aborts with `ServerPortAlreadyAllocatedError` ("Server port already used. Check for another software"). AWG on UDP/443 and Xray on TCP/443 on the same server is a normal setup, and it worked before 2026-08. ### Regression ``` $ git log -L 7,8:client/server_scripts/xray/run_container.sh --oneline d702dc0b fix: various fixes for Telemt, XRay (VLESS), Captcha (#2903) <- adds the /udp line d18423ee Feature/xray custom port (#965) <- tcp only ba4237f1 Xray with Reality protocol (#494) <- tcp only ``` Current content (`client/server_scripts/xray/run_container.sh`): ```sh sudo docker run -d \ --privileged \ --log-driver none \ --restart always \ --cap-add=NET_ADMIN \ -p $XRAY_SERVER_PORT:$XRAY_SERVER_PORT/tcp \ -p $XRAY_SERVER_PORT:$XRAY_SERVER_PORT/udp \ # <-- added in #2903 -v $CONTAINER_NAME-data:/opt/amnezia/xray \ --name $CONTAINER_NAME $CONTAINER_NAME ``` `start.sh` got a matching rule in the same commit: ```sh iptables -A INPUT -p udp --dport $XRAY_SERVER_PORT -j ACCEPT ``` Before #2903 the container published TCP only (March 2024 to August 2026), so AWG (UDP/443) and Xray (TCP/443) coexisted without issues. ### Why the UDP publish is unnecessary The Xray server config generated by the client only listens on TCP. In `client/core/models/protocols/xrayProtocolConfig.cpp`, `xrayEffective::network()` returns `tcp` for the default `raw` transport (with `reality`/`tls` security), so the single VLESS inbound has `streamSettings.network: "tcp"`. Nothing binds UDP/443 inside the container; the published UDP port only reserves host UDP/443 via `docker-proxy` and blocks AWG. The `MKCP` transport (`network: kcp`) does use UDP, but it is not the default, and the container port mapping is unconditional - it does not depend on the selected transport. ### Observed on a live server (2026-11-01) ``` $ docker inspect amnezia-xray | grep -A6 PortBindings "PortBindings": { "443/tcp": [ { "HostIp": "", "HostPort": "443" } ], "443/udp": [ { "HostIp": "", "HostPort": "443" } ] # <-- conflicts with AWG } ``` ``` $ docker ps 4dcff48fc457 amnezia-xray ... Up 2 minutes 0.0.0.0:443->443/tcp, 0.0.0.0:443->443/udp ``` ### Pre-flight check misses it too `InstallController::isServerPortBusy()` (`client/core/controllers/selfhosted/installController.cpp:881`) checks only the protocol's `defaultTransportProto`, which is `Tcp` for Xray (`protocolUtils.cpp:172`). The client therefore reports the port as free, and the failure only surfaces at `docker run`; AWG already occupying UDP/443 is not detected. ### Workaround Recreate the container without the UDP mapping (the data volume, and therefore `server.json` and the keys, survives): ```sh sudo docker stop amnezia-xray sudo docker rm amnezia-xray sudo docker run -d \ --privileged \ --log-driver none \ --restart always \ --cap-add=NET_ADMIN \ -p 443:443/tcp \ -v amnezia-xray-data:/opt/amnezia/xray \ --name amnezia-xray amnezia-xray sudo docker network connect amnezia-dns-net amnezia-xray ``` ### Suggested fix 1. Remove `-p $XRAY_SERVER_PORT:$XRAY_SERVER_PORT/udp` from `client/server_scripts/xray/run_container.sh` and the matching `iptables ... -p udp --dport $XRAY_SERVER_PORT` rule from `start.sh`. 2. If UDP must stay for the `MKCP` transport, publish it conditionally on the selected transport instead of always (adding the iptables rule only in that case). 3. Optionally, make `isServerPortBusy()` check the protocols the container will actually publish, so the conflict is reported before container creation. ### Environment - AmneziaVPN client 5.0.3.0; the server scripts are identical in current `dev` (HEAD `7f9b7db4`) - Server: Debian, Docker with the AmneziaWG kernel module loaded (`lsmod | grep amneziawg` -> `amneziawg`, `libcurve25519`) - Xray image: `amnezia-xray`, built from `XRAY_RELEASE=v26.7.28` - Reproduced on a fresh server: AWG installed first, Xray second
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#3233
No description provided.