Cannot connect to mysql server error for master replication
Using this mysql -h XXX -u -p you cannot connect to mysql remotely using root, if you want to connect with root remotely you have to configure it. For replication you need to create replication user on master and give it replication priviliges. 

example;

mysql> CREATE USER 'repl'@'%.example.com' IDENTIFIED BY 'password';

mysql> GRANT REPLICATION SLAVE ON . TO 'repl'@'%.example.com';

start your slave and check what is the error on IO thread also check slave log for any errors.