0

I can't connect from a different IP to the MySQL Server from a C# application.

The MySQL server works fine from localhost

SocketException: No connection could be made because the target machine actively refused it XXX.XXX.XX.XX:3306

What I've tried:

  • The user has access GRANT with the % hostname so it should be fine from an external IP
  • Currently the Ubuntu firewall is disabled for purposes of troubleshooting this
  • I have placed in the MySQL my.conf bind-address = 0.0.0.0 and #skip-networking

Still, the same error message prevails when trying to connect.

string connstring = string.Format("Server=XXX.XXX.XX.XXX;Port=3306; database={0}; UID=user; password=pswd", databaseName);
connection = new MySqlConnection(connstring);
connection.Open();

Any tips? Thanks!

Prashant Pimpale
  • 10,349
  • 9
  • 44
  • 84
user1202278
  • 774
  • 2
  • 10
  • 24
  • If you try to connect to the MySQL database from the same machine as your app, but using Workbench, is it successful? – ProgrammingLlama Aug 04 '18 at 03:16
  • Nope, connection also fails from Workbench – user1202278 Aug 04 '18 at 03:53
  • 1
    It's not a mysql permission issue, because that would result in a "access denied" error. The socket exception means, there is no service listening on port 3306 (at least none visible for a remote host). As you mentioned you disabled firewall and also set bind-address and #skip-networking, so forgive me if I'm asking: Are you sure you are connecting to the correct host? Did you restart the mysql service after you set these options? – derpirscher Aug 04 '18 at 04:39
  • The changes I was trying to make to the config file to allow all IP addresses were correct, they just were not applying to the server because it was the wrong config file being edited.... I've answered the question below. – user1202278 Sep 01 '18 at 05:54

1 Answers1

0

Solution : Config file was in a different location due to MySQL server version. Resolved by following this answer for version >= 5.7

Remote Connections Mysql Ubuntu

user1202278
  • 774
  • 2
  • 10
  • 24