rn-fetch-blob icon indicating copy to clipboard operation
rn-fetch-blob copied to clipboard

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

Open liushmh opened this issue 4 years ago • 6 comments
trafficstars

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

liushmh avatar Dec 20 '20 21:12 liushmh

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

dhamdani666 avatar Dec 27 '20 18:12 dhamdani666

Thanks, it works now

On Sun, Dec 27, 2020 at 1:28 PM Dadan Hamdani [email protected] 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 .

liushmh avatar Dec 28 '20 17:12 liushmh

Thanks @dhamdani666

PAVITHRA88 avatar Feb 21 '22 09:02 PAVITHRA88

Thanks @dhamdani666

@PAVITHRA88 how did you solve this in details

kim-gam-ja avatar Mar 04 '22 05:03 kim-gam-ja

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

magicleon94 avatar Dec 12 '22 14:12 magicleon94

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

Thank you magicleon94 and dhamdani666

Paul-prog44 avatar Feb 23 '24 16:02 Paul-prog44