Trying to make api requests through IP address using Expo [Windows Firewall]

I believe this must be firewall issue, and i can’t figure out what settings to change (on windows firewall) to make my api requests to my localhost.

I’ve read this post: Calling locally hosted server from Expo App

And it helped me get the right uri (on console.log it reads correctly):

http://(my IP)/apiAppOficios_v03/api/Requests/Contratista/login_contratista.php

But i still can’t connect to my local server on my pc, i keep getting this error:

[Unhandled promise rejection: TypeError: Network request failed]

My phone is on the same wifi of my computer, so that’s not the issue. I read this post: How to enable sharing of web site on localhost?

And apparently it’s a firewall issue, but step 5 and 6 don’t show up on my control panel, or maybe i’m not looking in the right direction. Does anyone know what could be the issue? and what configuration should i change?

So you’re running a Web server on your PC that you are trying to make requests to from your Expo app?

Can you access that URL from a web browser on your phone?

If not, it could be various things. It might not be the firewall.

Hi! i already solved it, i’m using ngrok now to give my api a fictional server, so now i can use my app on the phone with the expo app and hit the endpoints of my API.

1 Like

I am glad you have it working.

If I were to guess at the cause if the problem, your web server was probably listening on 127.0.0.1 only, which would mean you would only be able to access it from a browser running on the same machine. You would not be able to access it from your phone or another conputer using your PC’s IP address in this case, because the web server was not listening for requests on your wifi interface.

To fix that, you would need to find out how to make your web server listen on all interfaces instead of just “localhost” (127.0.0.1)

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.