Ionic: http://localhost/callback?code= could not be loaded because ERR_connection_refused

I’m trying to implement the sign-in with linkedin functionality in the ionic using rest-api method.

linkedinLogin() {
    this.platform.ready().then(() => {
      this.linkedinPage().then(success => {
        alert(success.access_token);
      },(error) => {
        alert(error);
      });
    });
  }

  linkedinPage(): Promise<any> {
    var self = this;
    return new Promise((resolve, reject) => {
      var browserRef = window.cordova.InAppBrowser.open('https://www.linkedin.com/uas/oauth2/authorization?client_id=' + this.clientId + '&redirect_uri=' + this.redirect_uri + '&scope=' + this.appScope + '&response_type=code&state=' + this.state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');
      browserRef.addEventListener("loadstart", (event) => {
        if((event.url).indexOf(this.redirect_uri) === 0) {
          try {
            var requestToken = (event.url).split("code=")[1].split("&")[0];
            let headers = new Headers();
            headers.append('Content-Type', 'application/x-www-form-urlencoded');
            this.http.post("https://www.linkedin.com/oauth/v2/accessToken?client_id='xxxx'&client_secret='xxxxxx'&redirect_uri=http://localhost/callback&grant_type=authorization_code&code=" + requestToken,
            {headers: headers})
            .subscribe(function(data){
              resolve(data);
              alert(data);
            })

          } catch(e) {
              setTimeout(function() {
                browserRef.close();
              }, 10);
            }
        }
        else {
          browserRef.addEventListener("exit", function(event) {
            reject("The linkedin sign in flow was canceled");
        });
        }
      });
  });
  }

I’m able to redirect to the linkedin page and ente my credentials allowing the linkedin to access the permission. After I’m getting a error message in the browser as
errr
Can someone say me why I’m facing this error and how can I resolve it?