无法加载资源:net::ERR_CONNECTION_REFUSED

Failed to load resource: net::ERR_CONNECTION_REFUSED

我正在使用此函数调用 REST 请求,但是,每当我使用按钮调用此函数时,我都会收到连接被拒绝的消息。我可以知道如何绕过这个问题吗?

function getContacts() {
    var settings = {
        "async": true,
        "crossDomain": true,
        "url": "http://localhost:5000/chaincode",
        "method": "POST",
        "headers": {
            "cache-control": "no-cache",
            "postman-token": "827ed81a-b8b4-d6a5-7e2c-e36f955b7423"
        },
        "data": "{\r\n  \"jsonrpc\": \"2.0\",\r\n  \"method\": \"query\",\r\n  \"params\": {\r\n      \"type\": 1,\r\n      \"chaincodeID\":{\r\n          \"name\":\"mycc\"\r\n      },\r\n      \"ctorMsg\": {\r\n         \"function\":\"query\",\r\n         \"args\":[\"a\"]\r\n      }\r\n  },\r\n  \"id\": 1\r\n}"
    }

    $.ajax(settings).done(function (response) {
        console.log(response);
    });
}

解决方案:

我正在使用 genymotion 模拟器,因此我无法绕过本地主机。我使用 http://10.0.3.2/ 作为主机号。然后问题就解决了。