Skip to content

Unhandled Exception: SocketException: Connection refused / Connection timed out, host: #135

Open
@TahaKh99

Description

@TahaKh99

I am trying to send a single value to mysql DB but I am keep getting these errors.
So first of all this is my code:

`
var settings = new ConnectionSettings(
host: 'localhost',
port: 3306,
user: 'flutter_admin',
password: 'flutter_admin_password',
db: 'romicp'
);final conn = await MySqlConnection.connect(settings);

var result = await conn.query( 'insert into bluetoothvalues (taha) values (?)',
    [3.66]);
print('Inserted row id=${result.insertId}');

}
`

With this code, I get this error: Unhandled Exception: SocketException: Connection refused.
So I was looking for solutions and i found out that this question was asked before and it was fixed by changing 'localhost' to ''10.0.2.2'' or your IPaddress. both ways gave me another error which is: Connection timed out, host:

Please anyone can help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions