How to fix 'SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.5.10, port = 49590' error in flutter

7,171

I used http package in flutter. And got the same error as yours. My solution is 'I used ngrok to expose my localhost' then I change my url to the url that ngrok forward. -Note: Use ngrok to test the api only. And when we host the to the server, there will not be any problems related to response time so you can use your server ip.

Share:
7,171
Amarjot Singh
Author by

Amarjot Singh

I am Backend Developer with 2 years of experience in Python and Django. I have experince in Javascript, Vue Js & Flutter also.

Updated on December 03, 2022

Comments

  • Amarjot Singh
    Amarjot Singh over 1 year

    I m trying to connect my android app to a Tcp iot server,first i connect to the tcp server using wifi then try socket connect but it is showing same error of connection timed out.

          print(r);
        }).catchError((e) {
          print(e);
        });
    

    wifi connects without any error.

    
    Socket.connect("192.168.5.10", 5800).then((socket) {
        print('Connected to: '
          '${socket.remoteAddress.address}:${socket.remotePort}');
        socket.destroy();
      });
    

    Here it shows Unhandled Exception: SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.5.10, port = 49590