Creating custom_webhook throwing 500 internal error, but curl is working fine


I have a slack webhook like below and its working fine both using REST client and curl;

curl -X POST -k -i ''

This request will publish message sample_text to my channel test_channel and can be viewed in slack app.

I tried below request from Kibana dev console;

POST _opendistro/_alerting/destinations
  "type": "custom_webhook",
  "name": "slack-destination",
  "custom_webhook": {
    "path": "api/chat.postMessage",
    "header_params": {
      "Content-Type": "application/json"
    "scheme": "HTTPS",
    "port": 443,
    "query_params": {
      "token": "test_token",
      "channel": "test_channel",
      "text": "sample_text"
    "host": ""

when I tried this, i got 500 internal error;

  "error" : {
    "root_cause" : [
        "type" : "alerting_exception",
        "reason" : "Connection refused"
    "type" : "alerting_exception",
    "reason" : "Connection refused",
    "caused_by" : {
      "type" : "exception",
      "reason" : " Connection refused"
  "status" : 500

Below is the Kibana trace;

Alerting - DestinationService - createDestination: { Error: [alerting_exception] Connection refused
    at respond (/kibana/node_modules/elasticsearch/src/lib/transport.js:349:15)
    at checkRespForFailure (/kibana/node_modules/elasticsearch/src/lib/transport.js:306:7)
    at HttpConnector.<anonymous> (/kibana/node_modules/elasticsearch/src/lib/connectors/http.js:173:7)
    at IncomingMessage.wrapper (/kibana/node_modules/lodash/lodash.js:4949:19)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  status: 500,
  displayName: 'InternalServerError',
  message: '[alerting_exception] Connection refused',
  path: '/_opendistro/_alerting/destinations?refresh=wait_for',
  query: {},
   { error:
      { root_cause: [Array],
        type: 'alerting_exception',
        reason: 'Connection refused',
        caused_by: [Object] },
     status: 500 },
  statusCode: 500,
   '{"error":{"root_cause":[{"type":"alerting_exception","reason":"Connection refused"}],"type":"alerting_exception","reason":"Connection refused","caused_by":{"type":"exception","reason":" Connection refused"}},"status":500}',
  toString: [Function],
  toJSON: [Function] }

Why is this happening? is there any relation with -k parameter of curl? Can somebody please tell me how to fix this?