3x-ui3x-ui

Environment Variables

Complete reference for 3x-ui's XUI_* environment variables — database, panel, logging, memory, and the tunnel health monitor.

3x-ui reads its runtime configuration from XUI_* environment variables. On a script install the installer writes them to the service environment file (/etc/default/x-ui, or /etc/conf.d/x-ui / /etc/sysconfig/x-ui depending on the distro); for Docker you set them in docker-compose.yml or docker run -e. Defaults are sensible — set only what you need to change, then restart: systemctl restart x-ui.

Database

VariableDefaultDescription
XUI_DB_TYPEsqliteBackend: sqlite, or postgres (also accepts postgresql / pg).
XUI_DB_FOLDER/etc/x-uiFolder for the SQLite database file (x-ui.db).
XUI_DB_DSNPostgreSQL connection string (used when XUI_DB_TYPE=postgres).
XUI_DB_MAX_OPEN_CONNSMax open connections in the PostgreSQL pool.
XUI_DB_MAX_IDLE_CONNSMax idle connections in the PostgreSQL pool.

The default SQLite database path is /etc/x-ui/x-ui.db. See Database for the SQLite ↔ PostgreSQL details.

Panel

VariableDefaultDescription
XUI_PORTOverride the panel port (1–65535). Takes precedence over the stored setting.
XUI_INIT_WEB_BASE_PATH/Initial web base path on first launch (e.g. /panel).
XUI_ENABLE_FAIL2BANtrueEnable Fail2ban-based IP-limit enforcement.
XUI_SKIP_HSTSfalseSkip the HSTS header — set true when TLS is terminated by a reverse proxy.

Logging & binaries

VariableDefaultDescription
XUI_LOG_LEVELinfodebug, info, notice, warning, or error.
XUI_DEBUGfalseDebug mode (forces log level to debug).
XUI_LOG_FOLDER/var/log/x-uiLog output directory.
XUI_BIN_FOLDERbinFolder for the Xray-core binary and geosite/geoip files.

Memory & profiling

The panel keeps memory low via GOGC and periodic releases. These are advanced knobs — leave them unset unless you're tuning a constrained host.

VariableDefaultDescription
XUI_GOGCGo GC target percentage; lower = less RAM, slightly more CPU.
XUI_MEMORY_RELEASE_INTERVALMinutes between FreeOSMemory calls; 0 disables.
XUI_MEMORY_LIMITGo soft memory limit in MiB.
GOMEMLIMITGo-syntax soft limit (e.g. 400MiB); takes precedence over above.
XUI_PPROFfalseExpose pprof profiling on 127.0.0.1:6060.

Xray

VariableDefaultDescription
XRAY_VMESS_AEAD_FORCEDfalseForce VMess AEAD.

Tunnel health monitor

Optional watchdog: it probes a URL (optionally through a local Xray inbound) and restarts Xray after repeated failures. A restart drops all connected clients, so enable it deliberately.

VariableDefaultDescription
XUI_TUNNEL_HEALTH_MONITORfalseEnable the monitor.
XUI_TUNNEL_HEALTH_PROXYProxy to send the probe through, e.g. socks5://127.0.0.1:1080. Empty = only checks host connectivity.
XUI_TUNNEL_HEALTH_URLhttps://www.cloudflare.com/cdn-cgi/traceURL to probe.
XUI_TUNNEL_HEALTH_INTERVAL30sInterval between probes.
XUI_TUNNEL_HEALTH_TIMEOUT10sPer-probe timeout.
XUI_TUNNEL_HEALTH_FAILURES3Consecutive failures before a restart.
XUI_TUNNEL_HEALTH_COOLDOWN5mMinimum delay between restarts.

Unattended install

VariableDescription
XUI_NONINTERACTIVESet to 1 (or run with no TTY) to install with zero prompts; generated credentials are written to /etc/x-ui/install-result.env. See Installation.

On this page