title: Unable to connect to a local mysql server in flutter
body: <p>In my flutter project I use &quot;mysql1&quot; package to connect with a mysql server, I tried it with an online server and it worked good.</p>
  <p>but when I tried to use it in a local server it didn't work but don't know what is the real problem.</p>
  <p>here is the class which called mysql1 package</p>
  <pre><code>import 'package:mysql1/mysql1.dart';
  
  class MySqlDB {
    static String host = 'localhost',
        user = 'root',
        password = 'admin',
        db = 'univ';
  
    static int port = 3306;
  
    Future&lt;MySqlConnection&gt; getConnection() async{
      var settings = new ConnectionSettings(
        host: host,
        user: user,
        password: password,
        port: port,
        db: db
      );
      return await MySqlConnection.connect(settings);
    }
  }
  </code></pre>
  <pre><code>And here is the problem message:
  E/flutter ( 5603): [ERROR:flutter/lib/ui/ui_dart_state.cc(213)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 59476
  E/flutter ( 5603):
  </code></pre>
  <p>&quot;update :</p>
  <p>I use Xampp app to run apache &amp; MySQL and phpmyadmin, so without this app there is no mysql on the laptop.</p>
  <p>The purpos of my project is just to run this app on the emulator.&quot;</p>
  <p>This image has myphp admin details:
  <a href="https://i.stack.imgur.com/RQZnM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RQZnM.jpg" alt="image: " /></a></p>
  <p>So..</p>
  <p>How can I fix it?</p>
  <p>I've tried many ways and see lot's of posts on stackoverflow but with no advanteges!!</p>