Hi,
When I call a web API from another web API within the same server, the external url parameter value of the final web API iin the httppost request doesn't seem to work but I have to give the localhost url - like this :localhost:8080/.../webapiname. Why is that and will this work in all environments? I understand it is not ideal to call this way, but I a little confused as to why the direct url is not working.
Discussion posts and replies are publicly visible
This usually happens because external URLs route through DNS, public IP, and network security layers. In many setups, an SMS firewall or network firewall can block or restrict these loopback requests.
localhost works because it bypasses those layers and stays inside the server.
localhost
But this isn’t reliable for all environments, especially in cloud or microservices setups. Best practice: Avoid internal HTTP calls and use direct service communication.