[GH-ISSUE #5299] [Bug]: Custom geofiles and routing rules causes xray fail on panel update #3710

Closed
opened 2026-10-31 20:34:24 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @ilya-practicum on GitHub (Jun 13, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5299

Describe the bug

If you run 3x-ui in docker and add rules with custom geofiles ext:geosite_custom.dat, for example. Then on next panel update xray will fail with error:

ERROR - XRAY: Failed to start: main: failed to load config files: [bin/config.json] > infra/conf: failed to build routing configuration > infra/conf: invalid field rule > common/geodata: illegal domain rule: ext:geosite_custom.dat:win-spy > common/geodata: failed to open geosite_custom.dat > stat /app/bin/geosite_custom.dat: no such file or directory

If you mount that file via volumes, then 3x-ui runs fine but that geofile will never be updated because of this error:

XRAY: app/geodata: scheduled geodata reload failed > multierr: rename /app/bin/geosite_custom.dat /app/bin/.geosite_custom.dat.888306995.bak: device or resource busy |

If you mount the whole folder, then xray will fail on start up with error:

Failure in running xray-core process: fork/exec bin/xray-linux-amd64: no such file or directory

May I ask to move custom geofiles to other folder, not bin. Then you will be able to mount that folder as volume and update files smoothly

How to reproduce the problem

  1. Add custom geofile and create rule for it
  2. Update panel with docker compose

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.3.1

Xray-core version

No response

How did you install 3x-ui?

Docker / Docker Compose

Operating system

Debian 13

Which parts of the panel are affected?

Docker image

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @ilya-practicum on GitHub (Jun 13, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5299 ### Describe the bug If you run 3x-ui in docker and add rules with custom geofiles ext:geosite_custom.dat, for example. Then on next panel update xray will fail with error: `ERROR - XRAY: Failed to start: main: failed to load config files: [bin/config.json] > infra/conf: failed to build routing configuration > infra/conf: invalid field rule > common/geodata: illegal domain rule: ext:geosite_custom.dat:win-spy > common/geodata: failed to open geosite_custom.dat > stat /app/bin/geosite_custom.dat: no such file or directory` If you mount that file via volumes, then 3x-ui runs fine but that geofile will never be updated because of this error: `XRAY: app/geodata: scheduled geodata reload failed > multierr: rename /app/bin/geosite_custom.dat /app/bin/.geosite_custom.dat.888306995.bak: device or resource busy |` If you mount the whole folder, then xray will fail on start up with error: `Failure in running xray-core process: fork/exec bin/xray-linux-amd64: no such file or directory` May I ask to move custom geofiles to other folder, not bin. Then you will be able to mount that folder as volume and update files smoothly ### How to reproduce the problem 1. Add custom geofile and create rule for it 2. Update panel with docker compose ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.3.1 ### Xray-core version _No response_ ### How did you install 3x-ui? Docker / Docker Compose ### Operating system Debian 13 ### Which parts of the panel are affected? Docker image ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:34:24 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 13, 2026):

The report is accurate. All three failure modes trace to the same root cause: the Xray binary and all geodata files share a single directory (/app/bin/ by default), which is not mounted as a Docker volume.

Why each failure happens

Problem 1 — custom geofile lost on update

The Dockerfile declares only one volume:

VOLUME [ "/etc/x-ui" ]

/app/bin/ is an ordinary image layer, not a volume. When docker compose pull && up -d recreates the container from the new image, any file you had placed in /app/bin/ in the old container is gone. The routing rules stored in the database (/etc/x-ui/x-ui.db, which IS persisted) still reference ext:geosite_custom.dat, so xray-core fails to start.

Problem 2 — bind-mounting a single file blocks xray-core's geodata reload

Bind-mounting a single file (./geosite_custom.dat:/app/bin/geosite_custom.dat) makes that path a bind-mount point in the container's mount namespace. The Linux rename(2) syscall returns EBUSY when the source path is a mount point. xray-core's internal scheduled geodata reload uses an atomic rename (to a .bak path) before replacing the file, so it fails with the error you see.

Problem 3 — mounting the whole bin directory hides the binary

/app/bin/ contains both the xray binary (xray-linux-amd64) and all geodata files (confirmed in DockerInit.sh). Mounting an empty host directory at /app/bin/ shadows the image's bin directory entirely, leaving no binary to execute.


Workaround available without code changes

xray-core reads the XRAY_LOCATION_ASSET environment variable to resolve geodata files (geosite.dat, geoip.dat, and ext:… custom files). The panel sets this to the bin folder path at startup only if it is not already present in the environment (internal/xray/api.go:380–387). This means you can override it from docker-compose.

Add a host directory mapped inside the existing /etc/x-ui volume and set XRAY_LOCATION_ASSET to it:

services:
  3xui:
    volumes:
      - $PWD/db/:/etc/x-ui/
      - $PWD/cert/:/root/cert/
    environment:
      XRAY_LOCATION_ASSET: "/etc/x-ui/geo"

Then on the host:

mkdir -p ./db/geo

# copy the standard dat files from a running container into the host directory
docker cp 3xui_app:/app/bin/geosite.dat ./db/geo/
docker cp 3xui_app:/app/bin/geoip.dat   ./db/geo/

# place your custom file in the same directory
cp geosite_custom.dat ./db/geo/

After docker compose up -d, xray-core will resolve all ext:… rules from /etc/x-ui/geo/, which survives container recreation. Since that directory is a plain directory bind-mount (not a single-file bind-mount), xray-core's rename-based geodata reload will not hit EBUSY.

Caveat: the panel's built-in "Update Geo Files" button/API (POST /server/updateGeofile) still downloads the standard files to /app/bin/ (internal/web/service/server.go:1585), which will differ from XRAY_LOCATION_ASSET. You will need to refresh the standard files manually (or by copying from /app/bin/ as above) until the panel's update logic is made aware of XRAY_LOCATION_ASSET.


Enhancement request

Separating the geodata directory from the binary directory (either by honouring XRAY_LOCATION_ASSET in UpdateGeofile, or by introducing a dedicated XUI_GEO_FOLDER env var that maps to a path that can be independently volume-mounted) would make this use case straightforward and would align UpdateGeofile with however xray-core actually resolves assets. Tracking this as an enhancement alongside the bug label.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4699771489 --> @github-actions[bot] commented on GitHub (Jun 13, 2026): The report is accurate. All three failure modes trace to the same root cause: the Xray binary and all geodata files share a single directory (`/app/bin/` by default), which is not mounted as a Docker volume. **Why each failure happens** *Problem 1 — custom geofile lost on update* The `Dockerfile` declares only one volume: ``` VOLUME [ "/etc/x-ui" ] ``` `/app/bin/` is an ordinary image layer, not a volume. When `docker compose pull && up -d` recreates the container from the new image, any file you had placed in `/app/bin/` in the old container is gone. The routing rules stored in the database (`/etc/x-ui/x-ui.db`, which IS persisted) still reference `ext:geosite_custom.dat`, so xray-core fails to start. *Problem 2 — bind-mounting a single file blocks xray-core's geodata reload* Bind-mounting a single file (`./geosite_custom.dat:/app/bin/geosite_custom.dat`) makes that path a bind-mount point in the container's mount namespace. The Linux `rename(2)` syscall returns `EBUSY` when the source path is a mount point. xray-core's internal scheduled geodata reload uses an atomic rename (to a `.bak` path) before replacing the file, so it fails with the error you see. *Problem 3 — mounting the whole bin directory hides the binary* `/app/bin/` contains both the xray binary (`xray-linux-amd64`) and all geodata files (confirmed in `DockerInit.sh`). Mounting an empty host directory at `/app/bin/` shadows the image's bin directory entirely, leaving no binary to execute. --- **Workaround available without code changes** xray-core reads the `XRAY_LOCATION_ASSET` environment variable to resolve geodata files (`geosite.dat`, `geoip.dat`, and `ext:…` custom files). The panel sets this to the bin folder path at startup only if it is not already present in the environment (`internal/xray/api.go:380–387`). This means you can override it from docker-compose. Add a host directory mapped inside the existing `/etc/x-ui` volume and set `XRAY_LOCATION_ASSET` to it: ```yaml services: 3xui: volumes: - $PWD/db/:/etc/x-ui/ - $PWD/cert/:/root/cert/ environment: XRAY_LOCATION_ASSET: "/etc/x-ui/geo" ``` Then on the **host**: ```bash mkdir -p ./db/geo # copy the standard dat files from a running container into the host directory docker cp 3xui_app:/app/bin/geosite.dat ./db/geo/ docker cp 3xui_app:/app/bin/geoip.dat ./db/geo/ # place your custom file in the same directory cp geosite_custom.dat ./db/geo/ ``` After `docker compose up -d`, xray-core will resolve all `ext:…` rules from `/etc/x-ui/geo/`, which survives container recreation. Since that directory is a plain directory bind-mount (not a single-file bind-mount), xray-core's rename-based geodata reload will not hit `EBUSY`. **Caveat**: the panel's built-in "Update Geo Files" button/API (`POST /server/updateGeofile`) still downloads the standard files to `/app/bin/` (`internal/web/service/server.go:1585`), which will differ from `XRAY_LOCATION_ASSET`. You will need to refresh the standard files manually (or by copying from `/app/bin/` as above) until the panel's update logic is made aware of `XRAY_LOCATION_ASSET`. --- **Enhancement request** Separating the geodata directory from the binary directory (either by honouring `XRAY_LOCATION_ASSET` in `UpdateGeofile`, or by introducing a dedicated `XUI_GEO_FOLDER` env var that maps to a path that can be independently volume-mounted) would make this use case straightforward and would align `UpdateGeofile` with however xray-core actually resolves assets. Tracking this as an enhancement alongside the bug label. *This reply was generated automatically; a maintainer may follow up.*
Sign in to join this conversation.
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
MHSanaei/3x-ui#3710
No description provided.