Hi,
Please read our FAQ regarding this error, here >> http://faq.webyog.com/content/23/15/en/error-no-2003-can_t-connect.html
Also please try to temporarily disable the firewall on the machine where it does not work in order to see if it is a local firewall issue. And also double-check the spelling of the hostname and the port.
You may also refer the mysql documentation here >> http://dev.mysql.com/doc/refman/5.7/en/can-not-connect-to-server.html
Regards,
Sibin