[GH-ISSUE #5806] [Bug]: Failed Fresh Install: PostgreSQL Connection Failed and Fail2ban installation Failed #4038

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

Originally created by @Masterain98 on GitHub (Jul 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5806

Describe the bug

I'm installing the latest version on a Rocky Linux 9 server, and got two issues that makes 3x-ui failed to start:

  1. The random generated PostgreSQL connection info is false and make the connection failure
  2. fail2ban failed to install and cause the IP limit feature disabled.

This might be the same error with #4876, but it happens again now.

Here are console output:

The OS release is: rocky
Arch: amd64
Running...
Last metadata expiration check: 0:04:26 ago on Sun 05 Jul 2026 02:48:10 PM CST.
Dependencies resolved.
Nothing to do.
Complete!
Beginning to install x-ui v3.4.2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 79.4M  100 79.4M    0     0  29.5M      0  0:00:02  0:00:02 --:--:-- 33.8M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  124k  100  124k    0     0  1728k      0 --:--:-- --:--:-- --:--:-- 1753k
x-ui/
x-ui/x-ui.service.debian
x-ui/x-ui.service.rhel
x-ui/x-ui.sh
x-ui/bin/
x-ui/bin/geoip.dat
x-ui/bin/README.md
x-ui/bin/LICENSE
x-ui/bin/mtg-linux-amd64
x-ui/bin/geoip_RU.dat
x-ui/bin/geosite_RU.dat
x-ui/bin/xray-linux-amd64
x-ui/bin/geosite_IR.dat
x-ui/bin/geosite.dat
x-ui/bin/geoip_IR.dat
x-ui/x-ui.service.arch
x-ui/x-ui
WebBasePath is missing or too short. Generating a new one...
Database initialization failed: failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000)
...
Certificate files installed successfully
Setting certificate paths for the panel...
failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000)
Certificate paths configured successfully
IP certificate installed and configured successfully!
Certificate valid for ~6 days, auto-renews via acme.sh cron job.
acme.sh will automatically renew and reload x-ui before expiry.
? Let's Encrypt IP certificate configured successfully
Access URL:  https://xxx.xxx.xxx.xxx:/21vGFzmKR5fwRbgFAK
2026/07/05 14:53:06 failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000)
Found x-ui.service.rhel in extracted files, installing...
Setting up systemd unit...
Setting up Fail2ban for the IP Limit feature...
The OS release is: rocky
Fail2ban is not installed. Installing now...!

Rocky Linux 9 - BaseOS                                                                                               23 kB/s | 4.3 kB     00:00    
Rocky Linux 9 - AppStream                                                                                            19 kB/s | 4.8 kB     00:00    
Rocky Linux 9 - Extras                                                                                               11 kB/s | 3.1 kB     00:00    
Metadata cache created.
Last metadata expiration check: 0:00:01 ago on Sun 05 Jul 2026 02:53:12 PM CST.
No match for argument: fail2ban
Package nftables-1:1.0.9-7.el9_8.x86_64 is already installed.
Error: Unable to find a match: fail2ban
Fail2ban installation failed.

Fail2ban setup did not finish; IP Limit stays disabled until you run 'x-ui' and open the IP Limit menu. Continuing.
x-ui v3.4.2 installation finished, it is running now...

How to reproduce the problem

Use the default install command to install 3x-ui, use default PostgreSQL installation and choose IP certificate.

Expected behavior

No response

Actual behavior

No response

Relevant logs

Jul 05 14:57:33 C202607051440251 x-ui[68847]: 2026/07/05 14:57:33 Error initializing database: failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000)
Jul 05 14:57:33 C202607051440251 systemd[1]: x-ui.service: Main process exited, code=exited, status=1/FAILURE
Jul 05 14:57:33 C202607051440251 systemd[1]: x-ui.service: Failed with result 'exit-code'.
Jul 05 14:57:38 C202607051440251 systemd[1]: x-ui.service: Scheduled restart job, restart counter is at 103.
Jul 05 14:57:38 C202607051440251 systemd[1]: Stopped x-ui Service.
Jul 05 14:57:38 C202607051440251 systemd[1]: Started x-ui Service.
Jul 05 14:57:38 C202607051440251 x-ui[68862]: 2026/07/05 14:57:38 Starting x-ui 3.4.2
Jul 05 14:57:38 C202607051440251 /usr/local/x-ui/x-ui[68862]: INFO - GC percent set to 75
Jul 05 14:57:38 C202607051440251 /usr/local/x-ui/x-ui[68862]: INFO - Go memory soft limit not enforced: no explicit budget; soft limit left at Go default
Jul 05 14:57:38 C202607051440251 x-ui[68862]: 2026/07/05 14:57:38 Error initializing database: failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000)
Jul 05 14:57:38 C202607051440251 systemd[1]: x-ui.service: Main process exited, code=exited, status=1/FAILURE
Jul 05 14:57:38 C202607051440251 systemd[1]: x-ui.service: Failed with result 'exit-code'.

Screenshots

No response

3x-ui version

3.4.2

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

Rocky Linux 9.2

Which parts of the panel are affected?

Install / upgrade script

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No — direct access

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 @Masterain98 on GitHub (Jul 5, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5806 ### Describe the bug I'm installing the latest version on a Rocky Linux 9 server, and got two issues that makes 3x-ui failed to start: 1. The random generated PostgreSQL connection info is false and make the connection failure 2. fail2ban failed to install and cause the IP limit feature disabled. This might be the same error with #4876, but it happens again now. Here are console output: ``` The OS release is: rocky Arch: amd64 Running... Last metadata expiration check: 0:04:26 ago on Sun 05 Jul 2026 02:48:10 PM CST. Dependencies resolved. Nothing to do. Complete! Beginning to install x-ui v3.4.2 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 79.4M 100 79.4M 0 0 29.5M 0 0:00:02 0:00:02 --:--:-- 33.8M % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 124k 100 124k 0 0 1728k 0 --:--:-- --:--:-- --:--:-- 1753k x-ui/ x-ui/x-ui.service.debian x-ui/x-ui.service.rhel x-ui/x-ui.sh x-ui/bin/ x-ui/bin/geoip.dat x-ui/bin/README.md x-ui/bin/LICENSE x-ui/bin/mtg-linux-amd64 x-ui/bin/geoip_RU.dat x-ui/bin/geosite_RU.dat x-ui/bin/xray-linux-amd64 x-ui/bin/geosite_IR.dat x-ui/bin/geosite.dat x-ui/bin/geoip_IR.dat x-ui/x-ui.service.arch x-ui/x-ui WebBasePath is missing or too short. Generating a new one... Database initialization failed: failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000) ... Certificate files installed successfully Setting certificate paths for the panel... failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000) Certificate paths configured successfully IP certificate installed and configured successfully! Certificate valid for ~6 days, auto-renews via acme.sh cron job. acme.sh will automatically renew and reload x-ui before expiry. ? Let's Encrypt IP certificate configured successfully Access URL: https://xxx.xxx.xxx.xxx:/21vGFzmKR5fwRbgFAK 2026/07/05 14:53:06 failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000) Found x-ui.service.rhel in extracted files, installing... Setting up systemd unit... Setting up Fail2ban for the IP Limit feature... The OS release is: rocky Fail2ban is not installed. Installing now...! Rocky Linux 9 - BaseOS 23 kB/s | 4.3 kB 00:00 Rocky Linux 9 - AppStream 19 kB/s | 4.8 kB 00:00 Rocky Linux 9 - Extras 11 kB/s | 3.1 kB 00:00 Metadata cache created. Last metadata expiration check: 0:00:01 ago on Sun 05 Jul 2026 02:53:12 PM CST. No match for argument: fail2ban Package nftables-1:1.0.9-7.el9_8.x86_64 is already installed. Error: Unable to find a match: fail2ban Fail2ban installation failed. Fail2ban setup did not finish; IP Limit stays disabled until you run 'x-ui' and open the IP Limit menu. Continuing. x-ui v3.4.2 installation finished, it is running now... ``` ### How to reproduce the problem Use the default install command to install 3x-ui, use default PostgreSQL installation and choose IP certificate. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell Jul 05 14:57:33 C202607051440251 x-ui[68847]: 2026/07/05 14:57:33 Error initializing database: failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000) Jul 05 14:57:33 C202607051440251 systemd[1]: x-ui.service: Main process exited, code=exited, status=1/FAILURE Jul 05 14:57:33 C202607051440251 systemd[1]: x-ui.service: Failed with result 'exit-code'. Jul 05 14:57:38 C202607051440251 systemd[1]: x-ui.service: Scheduled restart job, restart counter is at 103. Jul 05 14:57:38 C202607051440251 systemd[1]: Stopped x-ui Service. Jul 05 14:57:38 C202607051440251 systemd[1]: Started x-ui Service. Jul 05 14:57:38 C202607051440251 x-ui[68862]: 2026/07/05 14:57:38 Starting x-ui 3.4.2 Jul 05 14:57:38 C202607051440251 /usr/local/x-ui/x-ui[68862]: INFO - GC percent set to 75 Jul 05 14:57:38 C202607051440251 /usr/local/x-ui/x-ui[68862]: INFO - Go memory soft limit not enforced: no explicit budget; soft limit left at Go default Jul 05 14:57:38 C202607051440251 x-ui[68862]: 2026/07/05 14:57:38 Error initializing database: failed to connect to `user=fdLCm1OI database=xui`: 127.0.0.1:5432 (127.0.0.1): server error: FATAL: Ident authentication failed for user "fdLCm1OI" (SQLSTATE 28000) Jul 05 14:57:38 C202607051440251 systemd[1]: x-ui.service: Main process exited, code=exited, status=1/FAILURE Jul 05 14:57:38 C202607051440251 systemd[1]: x-ui.service: Failed with result 'exit-code'. ``` ### Screenshots _No response_ ### 3x-ui version 3.4.2 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system Rocky Linux 9.2 ### Which parts of the panel are affected? Install / upgrade script ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? No — direct access ### 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:36:42 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jul 5, 2026):

Both symptoms are confirmed, separate bugs in the current install.sh/x-ui.sh (v3.4.2), not something specific to your server.

1. PostgreSQL "Ident authentication failed"

install_postgres_local() in install.sh (around line 183) creates the random PostgreSQL role/database and builds a TCP DSN (postgres://<user>:<pass>@127.0.0.1:5432/xui?sslmode=disable), but it never touches pg_hba.conf. On RHEL-family distros (Rocky, AlmaLinux, RHEL, Fedora), postgresql-setup --initdb ships a default pg_hba.conf where TCP connections use ident auth, which checks the OS username against the Postgres role name — this always fails for a randomly generated role name, regardless of password. Debian/Ubuntu defaults use md5/peer, so the same installer works fine there, which is why this doesn't show up universally.

This is the same root cause as #4876, which was closed as fixed, but the fix does not appear to be present in the current source — install_postgres_local() still has no pg_hba.conf handling. It looks like it has resurfaced (or the earlier fix never actually landed).

Workaround until this is patched, on the affected server:

# find the actual hba file path
sudo -u postgres psql -tAc "SHOW hba_file;"

# add these two lines above the generic "ident" rules for host connections
# (use the PG-USER value shown in your own error/log line)
host    xui     <PG-USER>     127.0.0.1/32     scram-sha-256
host    xui     <PG-USER>     ::1/128          scram-sha-256

sudo systemctl reload postgresql
sudo systemctl restart x-ui

2. Fail2ban install failing ("No match for argument: fail2ban")

setup_fail2ban_iplimit() in x-ui.sh (around line 2288) runs, for the fedora | amzn | virtuozzo | rhel | almalinux | rocky | ol group:

dnf makecache -y && dnf -y install fail2ban nftables

with no EPEL setup first. fail2ban is not shipped in Rocky Linux's BaseOS/AppStream/Extras repos (as your log's Metadata cache created output shows) — it only exists in EPEL. The sibling centos branch of the same function does run yum install epel-release -y before installing on CentOS 7, but that EPEL step is missing for the rest of the RHEL family (Rocky/Alma/RHEL/Fedora/etc.), so it fails there.

Workaround:

sudo dnf install -y epel-release
sudo dnf install -y fail2ban nftables
x-ui setup-fail2ban

(x-ui setup-fail2ban re-runs the same routine and will pick up the now-installed fail2ban-client.)

Neither of these affects the panel binary itself — once PostgreSQL auth is fixed (issue 1), the panel will start; issue 2 only disables the IP Limit feature until fail2ban-client is present.

This reply was generated automatically by an issue-triage assistant; a maintainer may follow up.

<!-- gh-comment-id:4885178370 --> @github-actions[bot] commented on GitHub (Jul 5, 2026): Both symptoms are confirmed, separate bugs in the current `install.sh`/`x-ui.sh` (v3.4.2), not something specific to your server. **1. PostgreSQL "Ident authentication failed"** `install_postgres_local()` in `install.sh` (around line 183) creates the random PostgreSQL role/database and builds a TCP DSN (`postgres://<user>:<pass>@127.0.0.1:5432/xui?sslmode=disable`), but it never touches `pg_hba.conf`. On RHEL-family distros (Rocky, AlmaLinux, RHEL, Fedora), `postgresql-setup --initdb` ships a default `pg_hba.conf` where TCP connections use `ident` auth, which checks the OS username against the Postgres role name — this always fails for a randomly generated role name, regardless of password. Debian/Ubuntu defaults use `md5`/`peer`, so the same installer works fine there, which is why this doesn't show up universally. This is the same root cause as #4876, which was closed as fixed, but the fix does not appear to be present in the current source — `install_postgres_local()` still has no `pg_hba.conf` handling. It looks like it has resurfaced (or the earlier fix never actually landed). Workaround until this is patched, on the affected server: ```bash # find the actual hba file path sudo -u postgres psql -tAc "SHOW hba_file;" # add these two lines above the generic "ident" rules for host connections # (use the PG-USER value shown in your own error/log line) host xui <PG-USER> 127.0.0.1/32 scram-sha-256 host xui <PG-USER> ::1/128 scram-sha-256 sudo systemctl reload postgresql sudo systemctl restart x-ui ``` **2. Fail2ban install failing ("No match for argument: fail2ban")** `setup_fail2ban_iplimit()` in `x-ui.sh` (around line 2288) runs, for the `fedora | amzn | virtuozzo | rhel | almalinux | rocky | ol` group: ``` dnf makecache -y && dnf -y install fail2ban nftables ``` with no EPEL setup first. `fail2ban` is not shipped in Rocky Linux's BaseOS/AppStream/Extras repos (as your log's `Metadata cache created` output shows) — it only exists in EPEL. The sibling `centos` branch of the same function does run `yum install epel-release -y` before installing on CentOS 7, but that EPEL step is missing for the rest of the RHEL family (Rocky/Alma/RHEL/Fedora/etc.), so it fails there. Workaround: ```bash sudo dnf install -y epel-release sudo dnf install -y fail2ban nftables x-ui setup-fail2ban ``` (`x-ui setup-fail2ban` re-runs the same routine and will pick up the now-installed `fail2ban-client`.) Neither of these affects the panel binary itself — once PostgreSQL auth is fixed (issue 1), the panel will start; issue 2 only disables the IP Limit feature until `fail2ban-client` is present. *This reply was generated automatically by an issue-triage assistant; 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#4038
No description provided.