By cyclops
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", {
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there @cyclops,
What I could suggest is checking what port your application has is binded to first. To do that SSH to your Droplet and then run:
- netstat -plant | grep 3000
Also another thing you could check is if your localhost resolves correctly to the 127.0.0.1 IP address:
- ping localhost
Another thing that you need to keep in mind is that you need to run the axios script from the Droplet itself in order for it to work.
Feel free to share the output of the commands here so I could try to further advise you.
Hope that this helps! Regards, Bobby
Hi @bobbyiliev ,
I’m facing same issue.
tcp 0 0 127.0.0.1:3000 0.0.0.0:*
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
But still getting this error http://mydomain.com:3000/login net::ERR_CONNECTION_REFUSED
I’m using axios in react to make calls to node js. In my react app that’s my API_URL for login.
const API_URL = "http://localhost:3000";
Ah! localhost resolved to 127.0.0.1
netstat showed 3000 binding to 0 0.0.0.0:3000 Not sure why, but it gives me an avenue to explore
Much appreciated!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.