• Support
  • Can't Access to a MySQL database from external Server

Hey guys
I've just trying my first VPS with aaPanel
Great Job! It's very simple and intuitive

Everything is fine by now, except I can't access to MySQL from other Server (remote access through PHP)
If I use my domain (host.neosmartness.com) I get this error: Network is unreachable
If I use my IP (178.18.248.203) I get this error: Connection refused
(Both the domain and the IP indicated correspond to the VPS with aaPanel.
I'm trying to access to a database from an external Server using PHP)


My Setup

Port 3306 open
![https://www.acahol.com/img/firewall.png]

Bind Address 0.0.0.0
![https://www.acahol.com/img/mysql.png]

and from phpMyAdmin I created a new user and I also added to root user this host
![https://www.acahol.com/img/phpmyadmin.png]

my PHP code is this (work fine using localhost)
![https://www.acahol.com/img/php.png]

I'm using
MySQL 10.4.14-MariaDB
phpMyAdmin 5.0

Did I miss something?
Any help wil be wellcome
Thanks

    ASLAN Whitelist the MySQL Port 3306 from Firewall, and it will work. 🙂

      ASLAN Install the security firewall plugin and add that 3306 port there. Worked for me that way.

        szone
        As my originial post shows, security firewall plugin is installed and port 3306 is opened



        My problem was that my Source Server (PHP) was rejecting the connection to the Remote Server (MySQL)
        All Setup on aaPanel was right (Remote Server)
        I made changes on csf (Source Server) and everything works fine now.

        Thanks for aaPanel, it is a great tool

          6 months later
          9 months later
          5 months later

          ASLAN
          Hi Sir,

          I try with your way. But I cannot access my db from other hosting.
          Can you help me?

          Thanks,
          May

            aaP_swe_mayhtike
            Hello, is the database on the same server as the website? If so, please configure the database address directly on the website: 127.0.0.1
            If not, is the specified IP the IP of the server of the website? Is port 3306 open on the firewall of the server provider?

              aaPanel_Kern
              I did port open 3306 at website server. and database server also.
              But still cannot access database.
              $con = mysqli_connect("xxxxxxxx","username","password","dyname");
              error message
              Warning: mysqli_connect(): (HY000/2002): Connection timed out in /var/www/lis/html/index.php on line 11
              Failed to connect to MySQL: Connection timed out

                aaP_swe_mayhtike
                Hello, your server cannot connect to port 3306 of the database. It is recommended to check whether port 3306 is open in the security group of the server provider? Is the system firewall open?

                  Connect with us: 📨 Telegram 💬 Discord Email: support@aapanel.com