Report this

What is the reason for this report?

Why can I call api port from React app using ip address, but not when I use “localhost”

Posted on February 28, 2020

I can call curl -s localhost:3030 from command line and get a good reply. But when I call using axios or fetch within my React app, I get net::ERR_CONNECTION_REFUSED.

For example, this works:

axios.post("http://159.89.183.155:3030/authentication", {

This does not work (net::ERR_CONNECTION_REFUSED):

axios.post("http://localhost:3030/authentication", {

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.