0

So I made a program that connects to my MySQL database that is hosted on my PC. Connecting via localhost works, but I want to connect to the database using my external IP, but it just gives me this error.

I have already port-forwarded the ports 80, 443 and 3306 that I have set for the website and database. The ports are also allowed in the firewall so I can't see the problem.

If anyone has any Idea on how to fix this please help.

Thanks.

MatoMatto
  • 1
  • 2
  • Did you start your MySQL server? – RiggsFolly Feb 01 '21 at 10:42
  • Did you amend the user account to be allowed to connect from a remote location? – RiggsFolly Feb 01 '21 at 10:43
  • the error means that there is no software listening on the port you are trying to connect. So (probably) firewall or NAT was not configured properly. you may try with a `port scanner` tool. Where is client that is trying to connect to the external IP ? – oleksa Feb 01 '21 at 10:43
  • I did start the MySQL server and I did make another user that has all access from anywhere. – MatoMatto Feb 01 '21 at 10:44
  • I used the port scanner now and it showed this: https://imgur.com/a/H0KXk3o And also the client is a friend from another country. – MatoMatto Feb 01 '21 at 10:47
  • Then is has to be a firewall issue. Basically that message say I got NO response from a connection attempt. So either the firewall is closed or the server is not started or you are using the wrong Port number, or the wrong IP Address – RiggsFolly Feb 01 '21 at 10:48
  • So I double checked the IP and port (https://prnt.sc/xyvfee) and made sure it was the correct one but I don't see the problem in the firewall either because I opened ports 80,443, 3306 inbound and outbound (https://prnt.sc/xyvixs | https://prnt.sc/xyvkg1) – MatoMatto Feb 01 '21 at 10:57
  • SQL Server by default has the remote connections disabled, could be a similar issue in MySQL? – Cleptus Feb 01 '21 at 11:04
  • Does this answer your question? [Mysql No connection could be made because the target machine actively refused it](https://stackoverflow.com/questions/22736396/mysql-no-connection-could-be-made-because-the-target-machine-actively-refused-it) – Cleptus Feb 01 '21 at 11:05
  • @Cleptus I tried that and it doesn't work but I also made sure that it is even possible to access phpmyadmin via my external IP address and it is so I still don't even know what the problem is. – MatoMatto Feb 01 '21 at 11:28
  • Also if it helps this is my connection string MySqlConnection conn = new MySqlConnection("datasource=89.143.161.185;port=3306;username=Mato;password=S**************;"); – MatoMatto Feb 01 '21 at 11:41

1 Answers1

0

Most likely you are getting the password wrong in the connection string. Have you set a password?

  • I did set a username and password (that isn't the default root), but as I said it works with the username and password via localhost sooo. – MatoMatto Feb 01 '21 at 10:59