kubernetes – kubectl exec with curl Connection refused

i cannot execute successfully a curl command inside a running pod

$ kubectl exec -t pulsar-pulsar-manager-79c6769595-xd596 -- bash -c "CSRF_TOKEN=$(curl -v  http://localhost:7750/pulsar-manager/csrf-token)"

connect to ::1 port 7750 failed: Connection refused
Trying 127.0.0.1:7750…
connect to 127.0.0.1 port 7750 failed: Connection refused
Failed to connect to localhost port 7750: Connection refused
0 0 0 0 0 0 0 0 –:–:– –:–:– –:–:– 0
Closing connection 0
curl: (7) Failed to connect to localhost port 7750: Connection refused

But when i login to the container and execute the command, there is no issue

$ kubectl exec -ti pulsar-pulsar-manager-79c6769595-xd596  -- bash
$ CSRF_TOKEN=$(curl  http://localhost:7750/pulsar-manager/csrf-token)

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 36 100 36 0 0 2400 0 –:–:– –:–:– –:–:– 2400

Read more here: Source link