Report this

What is the reason for this report?

Wordpress Error Establishing Database Connection

Posted on February 12, 2017

Can someone please help me with this, my Wordpress website always get this Error almost 2 times a week with Error Establishing Connection. I don’t know how to fix the issue, tried to ask for admin support but still the error is there.

This is the picture of the error - https://i.gyazo.com/6e282a49bd82c3a775e924ef657793eb.png

This is the plugins i am using on my wordpress site - https://gyazo.com/ebcc16a7b04151cc28a87c76fc364106 https://gyazo.com/c30f807fd552e0d658435a616527b7cb

please i need your help, my website almost down for 20mins or more depends on the time i check and reboot the droplets.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I am using 512 MB Memory / 20 GB Disk

@carpediem

That’s what I originally thought judging by what you’ve said regarding the error noted.

As I said in my previous response, it is possible to run a working stack on 512MB, but it’s not quite as easy as set and forget. You have to constantly tweak and tune configuration for all services running (NGINX, MySQL/MariaDB, PHP-FPM, Redis/Memcached, etc).

Plugins

From what I can see, you have ~30 plugins installed and active. That’s going to be taxing on limited resources.

The WP-Smush and EWWW plugins are redundant and taxing on the CPU as they both require CPU to handle smushing/compressing your images down.

The more images you upload and are processing, the more intensive. You don’t need them both, so I’d pick one or the other.

Caching

If you have Redis/Memcached installed, that’s going to chew up ~32-128MB of your RAM at any given time. The defaults are 64MB. Unless you need these services and are planning to run multiple servers, you’d be better off using PHP’s OpCode Caching. In most all cases, it’s going to be faster than Redis or Memcached as it’s handled by PHP natively and doesn’t need to be offloaded to a service.

Now, if you were running NGINX on one Droplet, PHP-FPM on another, your database on another, etc – (i.e. clustering) – then yeah, Redis or Memcached would be perfect.

Recommendations

I would recommend dropping Redis/Memcached and using PHP’s OpCode Caching for object cache. I would also choose either WP-Smush or EWWW, but not both. Additionally, reduce your plugins down to those you absolutely need – deactivate anything you aren’t using or don’t need.

Beyond those recommendations, it’s more of a challenge of tweaking and tuning, or upgrading your Droplet so that you have more RAM available. As noted above, I recommend 1GB minimum, but at least 2GB if you’re going to use this as a production Droplet that receives traffic so that you have the room you need to grow.

@carpediem

What size is your Droplet?

If it is MySQL that is crashing and this happens to be a 512MB Droplet, that may be the reason why. While it can be done, to an extent, running Apache/NGINX, MySQL/MariaDB, and PHP/PHP-FPM on one server with only 1 CPU and 512MB of RAM is increasing difficult and requires that you know how to tweak and tune the configuration to work within such constraints.

For a standard LAMP or LEMP Stack, I’d recommend 1GB minimum, 2GB preferred.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.