0

I am trying to connect to my localhost:8080 through my Flutter desktop app, but I am receiving this error

"Unhandled Exception: The remote computer refused the network connection."

this is my code :

class LoginRequestCall {
  static Future<ApiCallResponse> call({
    String? userName = '',
    String? password = '',
  }) {
    return ApiManager.instance.makeApiCall(
      callName: 'loginRequest',
      apiUrl: 'http://localhost:8080/HongLeong/LOGIN_REQUEST.do',
      callType: ApiCallType.POST,
      headers: {},
      params: {
        'UserName': userName,
        'Password': password,
      },
      bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
      returnBody: true,
    );
  }

  static dynamic messageID(dynamic response) => getJsonField(
    response,
    r'''$.RESPONSE.BASEL_RESPONSE.ErrEntity.MessageID''',
  );
  static dynamic userName(dynamic response) => getJsonField(
    response,
    r'''$.RESPONSE.BASEL_RESPONSE.UserName''',
  );
  static dynamic serverName(dynamic response) => getJsonField(
    response,
    r'''$.RESPONSE.RESPONSE_HEADER.server_name''',
  );

}

Any solution would be greatly appreciated.

1
  • Are you sure the server is running and listening on the correct port? Does curl http://localhost:8080/HongLeong/LOGIN_REQUEST.do work? Are you running any firewall that could be blocking the connection? Commented Feb 24, 2023 at 18:12

1 Answer 1

0

Instead using the 'localhost' you have to use your system's IP address like.

"http://3.93.240.49:8080/HongLeong/LOGIN_REQUEST.do"

You can get the system's IP address by typing the 'ipconfig ' in command prompt.

Sign up to request clarification or add additional context in comments.

1 Comment

im afraid it still does not work, Ive tried using the ipv4 from "Ethernet adapter Ethernet".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.