mysql1_dart
mysql1_dart copied to clipboard
SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 35396
Tried sql for the first time but i am getting this error SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 35396
my code: var settings = new ConnectionSettings( host: 'localhost', port: 3306, user: 'flutter_admin', password: 'flutter_admin_password', db: 'flutter_admin' ); final conn =await MySqlConnection.connect(settings);
var result = await conn.query(
'insert into location (id, live_location) values (?, ?)',
['Bob', 25]);
print('Inserted row id=${result.insertId}');
please help me, Thanks
Hey guys!
I have the same error like @dhruv048. I found a different behaviour between simple dart-code (Package integrated in Console-App.) and flutter-code (Package integrated in Mobile-Application.). Also interesting: the port is incremented by 2 after retrying the connection.
ERROR-MESSAGE: https://hastebin.com/vagifadiva.yaml
Code is simplified.
FLUTTER-CODE-EXAMPLE (android: 10.0.15): https://hastebin.com/emolimaxal.java
DART-EXAMPLE: https://hastebin.com/fikoseyihi.js
I would be really thankful, if you can fix this error. The package is actually really fine.
I found a solution on Stack Overflow that helped me with this problem. By replacing host: 'localhost'
with host: '10.0.2.2'
It seemed to work perfectly.
@DansMatee
Yeah possible solution, but I'm still getting this error using a IP of a server, where mysql is installed. Do you have a solution or idea for that?
replacing the host for "10.0.2.2" did the trick for me, another detail is that if you are getting a conection refused, despite you having no password just comment the password in ConnectionSettings
I found a solution on Stack Overflow that helped me with this problem. By replacing
host: 'localhost'
withhost: '10.0.2.2'
It seemed to work perfectly.
thanks your solution is worked for me
All Possible solution added [Solved] SocketException: OS Error: Connection refused, errno = 111 in flutter
in my case , instead of local address , i use ethernet ip address ( wireless ) , my android emulator cant ping my local macbook.
In case if you use Django as your backend, you need to run with python manage.py runserver your_ip:port
. And replace your localhost IP address to Django ip address in flutter project if you are trying to run on an iPhone device.