How to setup replication between my two ISPConfig3 servers-Collection of common programming errors

So, I found the problem. My master database was not configurated for external connection.

I have reconfigured my installation and it was working but when I tested by creating a table, my server became extremely slow!

To resolve that, I didn’t had another choice except to reboot. After that, the server working properly again but when I re-tested them it crashed again!

I concluded I have a problem in my replication database with my master DB and my slave DB, may be on the connection?

Actualy, when I go to my phpmyadmin interface I receive a 502 Bad Gateway! The log are:

/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

I am stuck here, how I can fix that? Any ideas?