[vc_row][vc_column][vc_single_image image=”6623″ img_size=”full”][/vc_column][/vc_row][vc_row][vc_column][vc_row_inner][vc_column_inner][vc_column_text]I had a customer come to me recently with an issue they were facing with their WordPress site. They were receiving the dreaded “Error Establishing a Database Connection” most the time when visiting their site. This error did not happen every time so they did not have an actual database related issue but pretty often. I started to look at the web host Digital Ocean trying to narrow down the issue. I searched around and found a bunch of sites had the same issue that we were experiencing “Error Establishing a Database Connection”.
I tried several plugins and verified that our wp-config.php file had the correct settings. Then I found a solution that worked without the need of plugins that would consume server resources.
The issue was because their site was being XML-RPC attacked using up all of the database workers. I know this because I looked at the server DB workers we had 20 at that time and they were all being used and timing out. So I increased the workers to 50 and well they were all immediately filled up and now page refresh time was also affected. I reverted that change and looked for a solution and that fix was super simple.
I did the following to resolve their issue.
Placing the code below at the top of the .htaccess file located in the root of your WordPress site.[/vc_column_text][/vc_column_inner][/vc_row_inner][/vc_column][/vc_row][vc_row][vc_column width=”1/4″][/vc_column][vc_column width=”1/2″][vc_column_text]
# Block WordPress xmlrpc.php requests <Files xmlrpc.php> order deny,allow deny from all allow from 220.127.116.11 </Files>
[/vc_column_text][/vc_column][vc_column width=”1/4″][/vc_column][/vc_row][vc_row custom_notification_note=”” row_margin_top=”20px” row_padding_top=”20px”][vc_column][vc_column_text]
Did this fix work for you, if so let us know in the comments below?