Database connection error on WordPress on AWS EC2 | Blog - RickyGao Pty Ltd
14347
post-template-default,single,single-post,postid-14347,single-format-standard,ajax_fade,page_not_loaded,,qode_grid_1300,footer_responsive_adv,qode-child-theme-ver-1.0.0,qode-theme-ver-10.1,wpb-js-composer js-comp-ver-5.0.1,vc_responsive

Database connection error on WordPress on AWS EC2

Database connection error on WordPress on AWS EC2

We have recently identified that Amazon EC2 instance is not very stable on memory allocation. Especially on the FREE tier EC2 micro instance, but still occasionally happening on EC2 small instance.

The behaviour of the issue is administrator cannot login into WordPress backend anymore, but most of the time the site is still up and running (might because of we have cache enabled?)

image

If you can still SSH to the instance, you might see the error like below:

sudo su

cd /var/log/httpd/

tail -n 300 error_log | more

image

[Tue Oct 11 16:29:45.555168 2016] [mpm_prefork:error] [pid 2737] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process

Let’s check the server memory usage?

image.png

We still have so much memory.

 

Resolution:

The only resolution we’ve found is reboot the EC2 instance

image.png