从容器连接到远程数据库服务器时出错

I have a service deployed in mesos, which queries a remote database server. I used github.com/go-sql-driver/mysql to query the database from my Go code. It was working fine for about a week. But today I got this error: driver: bad connection

So I entered the docker container where my service runs and type in command line:

mysql -uxxx -hx.x.x.x -Pxxx -Dxxx -pxxx

Here's the response:

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

This is the content of /etc/mysql/my.cnf file:

[mysql]
no-auto-rehash  # Faster start of mysql but no tab completition

What can be the error here? And how can I solve this?

Edit: When I run the same command from my local machine it works fine. I can query the database from the command line of my pc.