'XAMPP receives "Connection refused" when curling other localhosts

I've a Reactjs app (NodeJS) running on localhost:3000 as well as a local blockchain node (Hardhat) running on localhost:8545.

There's no issues with those two communicating with each other, but I also have a XAMPP server running locally on localhost:8080 with a php app that returns some values.

I can reach all these localhosts fine through the browser.

But I need the php to communicate with my blockchain node. But the connection keeps getting refused when Xampp tries to create the connection to the node.

I even tried a basic curl from Xampp's terminal, and Xampp can't reach the other localhosts at all (tried both http://localhost:port and http://127.0.0.1:port). For instance if I just wanted to curl my react app (html) from Xampp's terminal like this...

curl http://localhost:3000/ -v

I get this...

*   Trying ::1...
* TCP_NODELAY set
* connect to ::1 port 3000 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* connect to 127.0.0.1 port 3000 failed: Connection refused
* Failed to connect to localhost port 3000: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 3000: Connection refused

Yes, I can curl things like google.com fine from within Xampp's terminal with no issues. It's just my localhosts. Yes, I have enabled curling in php. Yes, I can curl my react app (html) just fine from a separate terminal window. I'm on MacOS 12.1.

Thanks in advance for any help!!

Edit: I did some research, and I believe the issue is that the Xampp virtual machine can't reach my localhost. I've tried resolving this at the host file level to redirect a domain name to 127.0.0.1, but that doesn't work either. I'm still stuck, but wanted to put an update in case this info is helpful.

Last edit: I gave up.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source