Ubuntu 24.04, LEMP, Wordpress. After install and setup of wordpress I get "Error establishing a database connection" [closed]

2 weeks ago 16
ARTICLE AD BOX

After, what feels like, trying everything + deleted/created vps 20 times over the past weeks i need some help

Problem: After install/setup wordpress i get "Error establishing a database connection"

My setup: Ubuntu 24.04, Nginx 1.28.0, Php 8.4 / Php-fpm, Mysql 8.4, Wordpress 6.9, http/3, ufw, fail2ban

Permissions, owner, added nginx user (www-data to the owner of websitefiles group)

/var/www/html/wpfiles

sudo chown -R myuser:myuser /var/www/html/wpfiles

sudo chmod -R u=rwX,g=rX,o= /var/www/html/wpfiles

sudo usermod -a -G myuser www-data

Changes i did in www.conf

/etc/php/8.4/fpm/pool.d/www.conf

user myuser group myuser listen.owner myuser listen.group myuser

Logs

/var/log/nginx/error.log

2026/01/10 14:23:10 \[error\] 19910#19910: \*121 directory index of "/var/www/html/" is forbidden, client: xxx.xxx.xxx.xxx, server: mydomainname, request: "GET / HTTP/1.1", host: "mydomainname" 2026/01/10 14:23:12 \[error\] 19910#19910: \*122 directory index of "/var/www/html/" is forbidden, client: xxx.xxx.xxx.xxx, server: mydomainname, request: "GET / HTTP/1.1", host: "mydomainname" 2026/01/10 14:24:08 \[error\] 19910#19910: \*139 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "HTTP_HOST" in /var/www/html/mydomainname/public/wp-includes/functions.php on line 6344" while reading response header\> 2026/01/10 14:24:09 \[error\] 19910#19910: \*141 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "HTTP_HOST" in /var/www/html/mydomainname/public/wp-includes/functions.php on line 6344; PHP message: PHP Warning: Un\>

/var/log/mysql/error.log

2026-01-11T13:21:29.456623Z 1 \[System\] \[MY-013577\] \[InnoDB\] InnoDB initialization has ended. 2026-01-11T13:21:29.579362Z 0 \[Warning\] \[MY-010068\] \[Server\] CA certificate ca.pem is self signed. 2026-01-11T13:21:29.579385Z 0 \[System\] \[MY-013602\] \[Server\] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2026-01-11T13:21:29.597484Z 0 \[System\] \[MY-011323\] \[Server\] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock

/var/log/php8.4-fpm.log

\[11-Jan-2026 13:21:28\] NOTICE: fpm is running, pid 809 \[11-Jan-2026 13:21:28\] NOTICE: ready to handle connections \[11-Jan-2026 13:21:28\] NOTICE: systemd monitor interval set to 10000ms

What info do you guys need to help point me in the right direction?

Read Entire Article