MySQL running out of memory
1GB is "tiny" today.

Swapping is terrible for MySQL performance, so it is important not to tune things too big.

max_allowed_packet -- dangerously high, change to 30M; if you really need more than that, then either get more RAM, or we can dig deeper to find some other solution.

Change max_connections to, say, 40.

Change open_files_limit to, say, 1000.

Can you ferret out the specific error when "establishing a database connection"?  That might help, too.