Can not access localhost endpoint from local drone webhook plugin

I am testing plugins/webhook locally using drone exec, trying to test on the local endpoint which is running on http://localhost:5001/endpoint
drone yaml:

steps:
- name: test
  image: alpine
  commands:
  - echo hello
  - echo world
- name: send
  image: plugins/webhook
  network_mode: host
  settings:
    urls: http://localhost:5001/endpoint
    debug: true

Tried to set the network mode to host but still not working.
After using command “drone exec --trusted” i am getting error: Failed to execute the HTTP request. Post http://localhost:5001/endpoint/: dial tcp [::1]:5001: connect: connection refused. Am I missing something?

localhost refers to the network inside the container, so it is expected that localhost cannot be used to connect to an address outside of the container.

Is there any way to connect to localhost from the pipeline container?

This is more of a docker question than a drone question, so I would recommend checking stackoverflow. here is a thread that might be helpful nginx - From inside of a Docker container, how do I connect to the localhost of the machine? - Stack Overflow

With network mode set to host this really should work. Does drone properly push that from the config?

Basic test…
On host run…

$ python -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

Open a new terminal and run…

$ docker run -it --network=host python bash #it includes wget...
root@d34db33f: wget localhost:8000