I'm running a flutter app and trying to receive a json from localhost using:
Future<String> getJson() async {
http.Response response = await http.get(
Uri.encodeFull("http://localhost:3000/get"),
headers: {
"Accept": "application/json"
}
);
Whenever I run the app, I get an unhandled exception:
SocketException: OS Error: Connection refused, errno = 111, address = 127.0.0.1, port = 48134
The port 48134 is open. Now, I thought of maybe changing my listening port to the port above. Doing that, switches the port in the error to some other random port and giving the same error.
I don't understand why it's even looking for that port. It's not written anywhere.
Anyone has any ideas? Thanks in advance.