Network is unreachable : Http request from Canister

I am trying to send slack notifications using the HTTP method

    public func sendSlackMessage() : async {
        #Ok : Text;
        #Err : Text;
    } {

        let host : Text = "";

        // prepare system http_request call

        let request_headers = [
            { name = "Host"; value = host # ":443" },
            { name = "User-Agent"; value = "http_weather_canister" },
            { name = "Content-Type"; value = "application/json" },
        let url = "https://" # host # "/services/T02MG/BRMW/w6F5Dor";

        let body : JSON.JSON = #Object([
            ("text", #String("Danny Torrence left a 1 star review for your property."))

        let request : Types.CanisterHttpRequestArgs = {
            url = url;
            max_response_bytes = ?MAX_RESPONSE_BYTES;
            headers = request_headers;
            body = ?Blob.toArray(Text.encodeUtf8(;
            method = #post;
            transform = ?(#function(transform));

        try {
            let ic : Types.IC = actor ("aaaaa-aa");
            let response : Types.CanisterHttpResponsePayload = await ic.http_request(request);
            switch (Text.decodeUtf8(Blob.fromArray(response.body))) {
                case null {
                    throw Error.reject("Remote response had no body.");
                case (?body) {
        } catch (err) {

while running this coded I am getting the following error message.

  "Err": "Failed to connect: error trying to connect: tcp connect error: Network is unreachable (os error 101)"

Link for the candid : ICSCAN

Any idea why I am getting this error and how to resolve it?

1 Like

Does the server you want to connect to support IPv6? My quick check of the domain suggests that this is not the case. Note that the feature currently only supports IPv6, thus IPv4-only sites are not supported as of now.

Indeed, the remote host does not have a AAAA DNS record, and hence cannot be reached over IPv6.

Thank you for your response.
Just wondering, then why it is working on the local environment.

You probably have an IPv4 stack locally as well as an IPv6 stack, or at least carrier-grade NAT for one of them. IC nodes currently have only an IPv6 stack and there is no IPv4 compatibility initially. That explains why it works locally, but not once deployed.

This is something to be added to the documentation as potentially different behaviour of the local environment compared to the deployment on mainnet.