joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 770 forks source link

android connect error when RNFetchBlob.fetch url includes localhost or 127.0.0.1 #704

Open liushmh opened 3 years ago

liushmh commented 3 years ago
const url= `http://127.0.0.1:3000/api/info`
await RNFetchBlob.fetch('GET', url, {});

when running it on IOS virtual device, it works fine, running it on Android virtual device, if set url with http://127.0.0.1:3000/api/info , get an error: Failed to connect to /127.0.0.1:3000 if set url with http://localhost:3000/api/info , get an error: Failed to connect to localhost/127.0.0.1:3000

dhamdani666 commented 3 years ago

@liushmh brother you can set IP address local can't localhost , change localhost to IP address

liushmh commented 3 years ago

Thanks, it works now

On Sun, Dec 27, 2020 at 1:28 PM Dadan Hamdani notifications@github.com wrote:

@liushmh https://github.com/liushmh brother you can set IP address local can't localhost , change localhost to IP address

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/joltup/rn-fetch-blob/issues/704#issuecomment-751500895, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCROE5ZGJ6QLHQWVKBRT33SW54DVANCNFSM4VDL7MLA .

PAVITHRA88 commented 2 years ago

Thanks @dhamdani666

redvelvet-fan commented 2 years ago

Thanks @dhamdani666

@PAVITHRA88 how did you solve this in details

magicleon94 commented 1 year ago

Afaik on Android you need to reference 10.0.0.2 in order to point to the host machine's localhost (from Android simulator). 127.0.0.1 is the virtual phone's localhost

Paul-prog44 commented 3 months ago

Dude, ive been stuck on this trying every library for 10 hours straight until I found this.

Thank you magicleon94 and dhamdani666