bitnami / vms

Bitnami VMs
https://bitnami.com
Other
207 stars 44 forks source link

[MariaDB/WordPress connection issue probabbly] Wordpress can not connect to DB #1634

Closed Kurt57 closed 2 months ago

Kurt57 commented 3 months ago

Platform

AWS

bndiagnostic ID know more about bndiagnostic ID

57f644d4-4081-b7b1-0857-7c0137676e44

bndiagnostic output

===== Begin of bndiagnostic tool output =====

✓ Resources: No issues found
? Connectivity: Found possible issues
? Mariadb: Found possible issues
? Processes: Found possible issues
✓ Wordpress: No issues found
? Apache: Found possible issues
✓ Php: No issues found

[Connectivity]

Server ports 22, 80 and/or 443 are not publicly accessible. Please check the following guide to open server ports for remote access:

https://docs.bitnami.com/general/faq/administration/use-firewall/

[Mariadb]

Press [Enter] to continue: Found recent error messages in the MariaDB error log:

2024-08-22 8:16:18 0 [ERROR] Aborting

Please check the following guide to troubleshoot MariaDB issues:

https://docs.bitnami.com/aws/apps/wordpress/troubleshooting/debug-errors-m ariadb/

[Processes]

One or more component's processes are not running:

mariadb not running

You can try to restart the process with the following command:

$ sudo /opt/bitnami/ctlscript.sh start COMPONENT_NAME

[Apache]

Found recent error or warning messages in the Apache error log. Press [Enter] to continue:

[Thu Aug 22 08:24:12.642206 2024] [proxy_fcgi:error] [pid 2054:tid 
140505845307136] [client **ip_address**:54770] AH01071: Got error 'PHP message: 
PHP Warning: mysqli_real_connect(): (HY000/2002): Connection refused in 
/opt/bitnami/wordpress/wp-includes/class-wpdb.php on line 1982'
 [Thu Aug 22 08:24:12.949306 2024] [proxy_fcgi:error] [pid 864:tid 
140505895663360] [client **ip_address**:54780] AH01071: Got error 'PHP message: 
PHP Warning: mysqli_real_connect(): (HY000/2002): Connection refused in 
/opt/bitnami/wordpress/wp-includes/class-wpdb.php on line 1982'
 [Thu Aug 22 08:24:13.250900 2024] [proxy_fcgi:error] [pid 2054:tid 
140505811736320] [client **ip_address**:54794] AH01071: Got error 'PHP message: 
PHP Warning: mysqli_real_connect(): (HY000/2002): Connection refused in 
/opt/bitnami/wordpress/wp-includes/class-wpdb.php on line 1982'

Please check the following guide to troubleshoot server issues:

https://docs.bitnami.com/general/apps/wordpress/troubleshooting/debug-erro rs-apache/

A high number of incoming requests originate from one or more unique IP addresses. This could indicate a bot attack. The following guide shows how to check for and block suspicious IP addresses. Press [Enter] to continue:

https://docs.bitnami.com/bch/apps/moodle/troubleshooting/deny-connections- bots-apache/

===== End of bndiagnostic tool output =====

bndiagnostic was not useful. Could you please tell us why?

it was successful

Describe your issue as much as you can

i am getting this issue while try to open my Wordpress website

Warning: mysqli_real_connect(): (HY000/2002): Connection refused in /opt/bitnami/wordpress/wp-includes/class-wpdb.php on line 1982 Connection refused

Error establishing a database connection This either means that the username and password information in your wp-config.php file is incorrect or that contact with the database server at 127.0.0.1:3306 could not be established. This could mean your host’s database server is down.

Are you sure you have the correct username and password? Are you sure you have typed the correct hostname? Are you sure the database server is running? If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress support forums.

gongomgra commented 3 months ago

Hi @Kurt57,

Thanks for using Bitnami. I have checked your bndiagnostic data and I have found a couple of errors. First, the MariaDB database is not running due to the next error:

2024-08-22  8:16:18 0 [ERROR] mariadbd: Can't create/write to file '/tmp/mysql-init' (Errcode: 2 "No such file or directory")
2024-08-22  8:16:18 0 [ERROR] Aborting

It is so weird you can not write into the /tmp folder. Can you run the command below and try to start MariaDB again?

sudo chown 777 /tmp

The other error I have found is that MariaDB is not monitored by Gonit. Did you update anything in its configuration? Apart from this, it looks like there are a few IP addresses performing a lot of requests to your website. We recommend you to check our guide about bots and how to block them in case it is necessary

https://docs.bitnami.com/virtual-machine/apps/wordpress/troubleshooting/deny-connections-bots-apache/

Bruce96389 commented 3 months ago

The error you're encountering indicates that your WordPress site is unable to connect to the MariaDB database. The Bitnami diagnostic tool output points to several potential issues, including MariaDB not running and connectivity problems. Here's how you can troubleshoot this:

Steps to Fix the Issue: Check if MariaDB is Running:

First, verify if MariaDB is running. You can do this by SSHing into your server and running the following command: bash Copy code sudo /opt/bitnami/ctlscript.sh status If MariaDB is not running, try starting it with: bash Copy code sudo /opt/bitnami/ctlscript.sh start mariadb If the database still doesn't start, check the MariaDB logs for more details: bash Copy code sudo tail -n 100 /opt/bitnami/mariadb/logs/mysqld.log Check Database Credentials:

Ensure that the database credentials in the wp-config.php file are correct. You can access the file by running: bash Copy code sudo nano /opt/bitnami/wordpress/wp-config.php Verify the database name, username, password, and hostname (usually localhost or 127.0.0.1): php Copy code define('DB_NAME', 'your_database_name'); define('DB_USER', 'your_database_user'); define('DB_PASSWORD', 'your_database_password'); define('DB_HOST', '127.0.0.1:3306'); Check Server Ports:

The diagnostic tool indicated that ports 22, 80, or 443 might not be accessible. This can affect your site's connectivity. Ensure that the ports are open: SSH into your server and run: bash Copy code sudo ufw allow 22 sudo ufw allow 80 sudo ufw allow 443 sudo ufw enable Check Apache Logs:

The Apache error log contains warnings related to database connections. To diagnose further, review the Apache logs: bash Copy code sudo tail -n 100 /opt/bitnami/apache2/logs/error_log Check for Bot Attacks:

If you notice a high number of incoming requests, it might indicate a bot attack. You can block suspicious IPs using the .htaccess file or through the server firewall. Restart the Services:

After making these changes, restart the services to see if it resolves the issue: bash Copy code sudo /opt/bitnami/ctlscript.sh restart YourTexasBenefits com If the issue persists after trying these steps, please provide any additional error logs, and I'll help further troubleshoot.

github-actions[bot] commented 2 months ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] commented 2 months ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.