skip to Main Content

I cannot connect to my database which is hosted on OVH remotely from Flutter’s package mysql1 and get the following error:

flutter: SocketException: Failed host lookup: ‘saintlouqpweb.mysql.db’
(OS Error: nodename nor servname provided, or not known, errno = 8)

I usually access it through phpMyAdmin where I have three fields to fill: the server, the user, and the password. I use exactly the same values than there with mysql1 on Flutter in addition to the database name (the server field of phpMyAdmin being the host field of mysql1).

I have searched for hours a solution but I still find nothing on this forum and on the web. Everything is always brought back to a ‘localhost’ server or a problem too different from mine.

Here is the piece of code causing the error :

Future<List<dynamic>> getData() async
  {
    try {
      final conn = await MySqlConnection.connect(ConnectionSettings(
        host: 'saintlouqpweb.mysql.db', // the exact server name entered on phpMyAdmin
        user: 'myusername',
        password: '*********',
        db: 'mydatabasename',
      ));

    var results = await conn.query(
      'SELECT * FROM `mytable` WHERE ID=1;'
    );

    return results.toList();
    } catch (e) {
      print('$e');
    }
  }

I would be grateful if someone can help me about that or experienced the same issue previously.

2

Answers


  1. As suggested by Mark Rotteveel in comment, the host you provided in code sample does not look valid.

    You can find you host address in your OVHcloud manager : https://www.ovh.com/manager/web

    It is accessible inside Web Cloud->Databases and in the table General Informations

    Login or Signup to reply.
  2. Based on the hostname it looks like you have a shared SQL database. According to this OVH community post remote connections are not allowed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search