2
db = await Db.create("mongodb://10.0.2.2:27017/bestchat");

I have mongoDB on my pc. if I try connect to mongo on emulator it works fine.

db = await Db.create("mongodb://192.168.1.33:27017/bestchat");

But on real device I use wifi network local ip like 192.168.1.33 and it not work. What the problem?

  • 1
    This may help you : https://stackoverflow.com/questions/59924840/how-to-connect-flutter-with-mongodb and did you added permission for internet in manifest file ? – Hardik Mehta May 18 '22 at 10:03
  • @HardikMehta I added this `` right now but it not work – Blink Dagger May 18 '22 at 10:13
  • also I get time out exception `ConnectionException (MongoDB ConnectionException: Could not connect to 192.168.1.33:27017 - SocketException: Connection timed out (OS Error: Connection timed out, errno = 110), address = 192.168.1.33, port = 33068)` – Blink Dagger May 18 '22 at 10:19
  • if you are in same network then you can try mongodb://10.0.2.2:27017/bestchat this way also. – Hardik Mehta May 18 '22 at 10:25

1 Answers1

1

OK, the reason is win firewall. I add rule for mongo and it works