Reputation: 31
import 'package:mongo_dart/mongo_dart.dart';
main() async{
Db db = new Db("mongodb://localhost:27017/workouts");
await db.open();
print("success ---------------------------------");
}
this symple code and dont connect, i dont know why. this is the output:
Syncing files to device Android SDK built for x86...
Restarted application in 306ms.
E/flutter ( 5415): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 52206
E/flutter ( 5415): #0 _ConnectionManager._connect (package:mongo_dart/src/network/connection_manager.dart:23:5)
.... and more logs
¿some help? :(
Upvotes: 0
Views: 3054
Reputation: 31
solved ==> https://stackoverflow.com/a/55786011/12369361
due to use emulator I need to use 10.0.2.2 instead of localhost
Upvotes: 3
Reputation: 686
I suppose that you have a local mongoDB server. If it is the case, you have to connect your local server and your android phone to the same network (through wifi).
Then get the IP of your local server and replacing localhost
in your url with the IP you found.
If you can't, it is possible that your firewall is blocking your requests.
Upvotes: 0