title: Flutter gRPC error - OS Error: Connection refused
body: <p>I am using protobuf and gRPC to exchange information between a Flutter app and a python server (client in Flutter and the server in python). Server running on 0.0.0.0 and the client is using the IP address of the server machine. </p>
  
  <pre><code>import 'dart:async';
  import 'User.pbgrpc.dart';
  import 'User.pb.dart';
  import 'package:grpc/grpc.dart';
  
  Future&lt;Null&gt; main() async {
    final channel = new ClientChannel('IP_ADDRESS',
        port: 50051,
        options: const ChannelOptions(
            credentials: const ChannelCredentials.insecure()));
    final stub = new StorageClient(channel);
  
    Test input = new Test();
    input.id = 1;
    try {
      var response = await stub.getPerson(input);
      print('Greeter client received: ${response}');
    } catch (e) {
      print('Caught error: $e');
    }
    await channel.shutdown();
  }
  </code></pre>
  
  <p>if I run this client using <code>dart client.dart</code> everything works fine and I get the expected response. But if I embed this method in a flutter app like:</p>
  
  <pre><code>@override
  Widget build(BuildContext context) {
  
  Future&lt;Null&gt; testRPC() async {
    final channel = new ClientChannel('IP_ADDRESS',
        port: 50051,
        options: const ChannelOptions(
            credentials: const ChannelCredentials.insecure()));
    final stub = new StorageClient(channel);
  
    Test input = new Test();
    input.id = 1;
    try {
      var response = await stub.getPerson(input);
      print('Greeter client received: ${response}');
    } catch (e) {
      print('Caught error: $e');
    }
    await channel.shutdown();
  }
  
  testRPC();
  ...etc
  }
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>I/flutter (18824): Caught error: gRPC Error (14, Error connecting: SocketException: OS Error: No route to host, errno = 111, address = localhost, port = 45638)
  </code></pre>
  
  <p><strong>UPDATE:</strong> It is working when I run the app with an emulator. So this is error is happening only when using a real device.</p>