Thank you for your answer. Yes, I am able to connect to UCSC's MySQL server. This is the output of mysql status:
mysql> status
--------------
mysql Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using EditLine wrapper
Connection id: 3761627
Current database:
Current user: genome@155.185.43.175
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.26-log MySQL Community Server (GPL)
Protocol version: 10
Connection: genome-mysql.soe.ucsc.edu via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 42 days 4 hours 16 min 11 sec
Threads: 15 Questions: 125628008 Slow queries: 14140 Opens: 26320782 Flush tables: 43 Open tables: 2000 Queries per second avg: 34.473
--------------
So do you suggest it is an issue on Ensembl end? But I emailed them and they said they cannot see a reason on their side why I would be able to establish a connection, but then loose it. So I really don't understand what can be the problem...