I am trying to test my mobile app using Expo Go but I am getting ‘network errors’. I am using Django and React Native. I am also using 127.0.0.1:8000 for the development settings and the client API_URL
That’s not going to work. The TCP address “127.0.0.1” is also known as “localhost”. It’s a reference to the current system. When your phone issues a request to 127.0.0.1, it’s looking for a web service on the phone itself.
Depending upon your specific environment, you’ll need to use your machine’s “visible” IP address. This will either be that system’s IP address, or your firewall/router box address. Or, if you have a domain name, you can use it, assuming it’s set up to resolve to your web server.
Sorry, I didn’t add that I am using Ubuntu OS and Oracle Virtual box machine, hosted on a windows system. I have tried both the guest and host machines IPs and they both gave me network error. I have deployment domain and a custom domain as follows; https://casblog.fly.dev and casblog.app. Are you saying that I can use any of them as the API_URL?
How do you have your virtual network configured? Is it a shared address or NAT? (What are the specific addresses?) You may also need to open the Windows firewall to allow access. (And, there may be firewall settings that you need to change on the Ubuntu system as well.)
If the addresses associated with them are correct, yes.
And it may also matter if your phone is connected to the same wifi access point or not.
Before worrying about your app / project, I would focus only on getting your phone able to connect to a default web page on your VM. I’d ignore everything else until you can get your phone to properly send an http request to your server.
(What webserver are you using? Nginx or Apache? Either way, in the absence of a configuration section for your Django project, they will by default provide a landing page.)
I am testing the mobile app with Django development server. The phone has now connected with the server using the Host (windows) machine’s IP and the app has opened on the phone’s browser. But I got the following error from the terminal ’ LOG LOGIN ERROR: Network Error
ERROR LOGIN FAILED FULL ERROR: [AxiosError: Network Error]
ERROR LOGIN FAILED RESPONSE: undefined
ERROR LOGIN FAILED DATA: undefined
ERROR LOGIN FAILED MESSAGE: Network Error’ after running ‘npx expo start --tunnel’. I have disabled the Host system’s firewall and the Ubuntu firewall is in inactive mode.
That sounds like an Expo issue - you’re going to be best off pursuing it with them, unless you can demonstrate a comparable error using a regular browser accessing the web site.
The issue is now resolved. I changed the guest machine’s network settings to bridged adapter instead of NAT, then I used the Ubuntu OS IP and it worked. Thanks for your help.