Question
Why can I call api port from React app using ip address, but not when I use “localhost”
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", {
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×