Cannot able to call localhost webhook via notification channels

I have created following notification channel which is pointing to localhost port
But while testing the channel i am getting below error

[status_exception] {"event_status_list": [{"config_id":"O9MvNZoBtPmWID2qR-hH","config_type":"webhook","config_name":"Zequre Detection","email_recipient_status":[],"delivery_status":{"status_code":"500","status_text":"Failed to send webhook message Connect to ``http://localhost:8080`` [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused"}}]}

Full error

[2025-10-30T14:20:08,574][INFO ][o.o.n.s.SendMessageActionHelper] [opensearch-node1] notifications:getSingleConfig-get O9MvNZoBtPmWID2qR-hH

[2025-10-30T14:20:08,607][ERROR][o.o.n.c.t.WebhookDestinationTransport] [opensearch-node1] Exception sending webhook message O9MvNZoBtPmWID2qR-hH: org.opensearch.notifications.spi.model.MessageContent@6739229d

org.apache.hc.client5.http.HttpHostConnectException: Connect to http://localhost:8080⁠ [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused

at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]

at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:628) ~[?:?]

at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:533) ~[?:?]

at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:583) ~[?:?]

at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:282) ~[?:?]

at java.base/java.net.Socket.connect(Socket.java:665) ~[?:?]

Can any one please suggest solution for it.

@imm31 What is the localhost? Is it a Docker host? How did you deploy your cluster?

No it is IP for the local spring boot server with port.

ex: http://localhost:8080/test

I have deployed the my cluster via docker with below compose file


services:

  opensearch-node1: # This is also the hostname of the container within the Docker network (i.e. https://opensearch-node1/)

image: opensearchproject/opensearch:latest # Specifying the latest available image - modify if you want a specific version

container_name: opensearch-node1

environment:

      - cluster.name=opensearch-cluster # Name the cluster

      - node.name=opensearch-node1 # Name the node that will run in this container

      - discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster

      - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligible to serve as cluster manager

      - bootstrap.memory_lock=true # Disable JVM heap memory swapping

      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM

      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=Password1 

      - plugins.security.restapi.admin.enabled=true

# Sets the demo admin user password when using demo configuration, required for OpenSearch 2.12 and later

ulimits:

memlock:

soft: -1 # Set memlock to unlimited (no soft or hard limit)

hard: -1

nofile:

soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536

hard: 65536

volumes:

      - opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container

ports:

      - 9200:9200 # REST API

      - 9600:9600 # Performance Analyzer

networks:

      - opensearch-net # All of the containers will join the same Docker bridge network

opensearch-node2:

image: opensearchproject/opensearch:latest # This should be the same image used for opensearch-node1 to avoid issues

container_name: opensearch-node2

environment:

      - cluster.name=opensearch-cluster

      - node.name=opensearch-node2

      - discovery.seed_hosts=opensearch-node1,opensearch-node2

      - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2

      - bootstrap.memory_lock=true

      - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"

      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=Password1

      - plugins.security.restapi.admin.enabled=true

ulimits:

memlock:

soft: -1

hard: -1

nofile:

soft: 65536

hard: 65536

volumes:

      - opensearch-data2:/usr/share/opensearch/data

networks:

      - opensearch-net

opensearch-dashboards:

image: opensearchproject/opensearch-dashboards:latest # Make sure the version of opensearch-dashboards matches the version of opensearch installed on other nodes

container_name: opensearch-dashboards

ports:

      - 5601:5601 # Map host port 5601 to container port 5601

expose:

      - "5601" # Expose port 5601 for web access to OpenSearch Dashboards

environment:

OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # Define the OpenSearch nodes that OpenSearch Dashboards will query

networks:

      - opensearch-net




volumes:

opensearch-data1:

opensearch-data2:




networks:

opensearch-net:

external: true

@imm31 This error is expected as http://localhost:8080 refers to the OpenSearch container instead of the host. You want to point to a service running on the Docker host as far as I understand.

Okay thank you for your response.

Is there any way to call the local running servers directly from the webhook channel?
I have tried with my IP also http://136.84.164.63:8080/test but that also throwing same error.

@imm31 If your container is running with i.e. 172.18.0.2/16 and the Docker host where the pod running is 192.168.1.160/24 and the same Docker host is running service on port 8080, then you can simply call 192.168.1.160:8080. Docker will route between its internal network and the Docker host with no issue.

Is this the IP address of the Docker Host or a different virtual machine that is running service on port 8080?

My opensearch container and my service both are running on same host,

I have used host.docker.internal as the host. Now it is calling.
Thank you for the responses @pablo

1 Like