Although it can be used for remote databases, usually if we have not configured it and try to connect remotely to CyberPanel, we will get the error message Lost connection to server at ‘handshake: reading initial communication packet’.
Perhaps if you search for a solution on Google, the answer is to update the bind-address, and that is indeed correct. But, how do we update the CyberPanel bind-address so that we do not get the message Lost connection to server at ‘handshake: reading initial communication packet’ when performing a remote database connection?
In this article, we will discuss how to resolve the CyberPanel ‘handshake: reading initial communication packet’ error, which certainly disrupts remote database activity.
Fixing CyberPanel ‘handshake: reading initial communication packet’
Make sure you can log in to the server SSH as an admin, and of course, log in to CyberPanel as an admin as well. Once you have done that, you can log in to SSH as the root user. Usually, you can use the command ssh root@server_ip -p 22.
After logging in, you can proceed to the next step.
1. Find and Edit the galera.cnf Configuration
The first step to changing the bind-address is to update the configuration in the file galera.cnf, and to find the galera.cnf file, you can use this command
cd /etc/mysql/mariadb.conf.d && lsAfter using the command above, an output will appear that looks something like this
From the screenshot above, the file that needs to be edited is 60-galera.cnf. The prefix number on your server might be different, so please adjust it accordingly.
Next, use the nano or vi editor to update galera.cnf
sudo cp 60-galera.cnf 60-galera.cnf.bak && nano 60-galera.cnfThe command above will create a backup of 60-galera.cnf named 60-galera.cnf.bak and will then automatically open the nano editor.
2. Update bind-address
By default, the bind-address in CyberPanel is localhost or 127.0.0.1 so you cannot perform a remote database connection, and only localhost or the server itself can access the database
Change the line bind-address = 127.0.0.1 to bind-address = 0.0.0.0 so that you can perform a remote database connection, then save by pressing CTRL + X if you are using the nano editor, or enter command mode and use the command :wq! if you are using the vi editor
3. Restart MySQL Service
For the changes to take effect, you need to restart the MySQL service first using the following command
sudo systemctl restart mysqldOnce restarted, you can check the firewall and allow port 3306, or any other port you use for database connections.
4. Open Port in Firewall (Optional)
If you have a firewall enabled on your server, you need to open the port 3306 to perform a remote database connection. This applies whether the firewall uses UFW, CSF, or the default CyberPanel firewall.
A. Open Port Using UFW
If you are using UFW, you can check the firewall status first using this command
sudo ufw statusIf the status is enabled but port 3306 is not yet open for remote database connections, you can open the port using this command
sudo ufw allow 3306/tcpNow you can try to perform a remote database connection. However, if the port still results in an error, there might be another firewall you are using.
B. Open Port Using CSF
If CSF is active and installed on your server, you can open port 3306 through the CSF page. First, log in to the CyberPanel dashboard as an admin user, then open the page Security → CSF
After being on the CSFpage, you will get the option to enter the ports allowed to connect, and here you need to open the port 3306 in the TCP IN Portsoption, for example like this
After the port is opened, you can try to perform a remote database connection.
3. Open Port Using Default Firewall
If you are not using CSF but are using the default firewall, you can open remote database access through the page Security → Firewall.
After being on the firewall page, give the firewall rule a name you want to save, for example Remote DB, then for the connection type use TCP and the IP address column can be filled with the IP address you are using, or you can use 0.0.0.0/0 to allow a global remote database connection. Finally, for the port, you can fill it with 3306 or another port used by your database
After saving, you can try to perform a remote database connection in CyberPanel by following the tutorial on this page: How to Remote Database in CyberPanel Hosting
COMMENTS
Loading...