Wordpress“连接丢失了。 保存已被禁用“仅在发布到Amazon EC2时出错

This is happening everytime I try to write/submit new post to my wordpress site hosted on Amazon EC2 micro instance.

Error I get "Connection lost. Saving has been disabled until you’re reconnected. We’re backing up this post in your browser, just in case."

I started getting this error when I upgraded to Wordpress 4.0, as suggested on stackoverflow I downgraded to 3.9, it went fine for a month but again this problem has resurfaced.

I get connection lost and it is always followed by

"Error establishing a database connection"

My local host works absolutely fine(with exactly same site), never giving an error. It has to do something about Wordpress + Amazon.

I don't think it has to do anything with the Swap Memory or anything like that because I can easily make a post using Microsoft Word. Plus my site is fairly new with just 2 to 5 users at a time.

Please help me, this is annoying. I have to restart the server every time to get rid of this.

To be able to diagnose your problem, we would need more details

Where is running your database ? Is it on the same EC2 instance, another one or RDS ? What instance type are you using ?

A likely cause is a database memory problem. On t2.micro instances, there is not enough memory to keep the OS, the database and the web server running at the same time.

You'll have to create a swap file and add it to the OS (see "Stopping MSQL from crashing" in https://gist.github.com/rozeykex/7882972)