'React Native Network Error using local api

Current setup:

  • Using iOS and actual phone + React Native metro bundler + axios for api

My problem:

  • I cannot use api that is local, but api on the main server has no issues
  • The error is simply just "ERROR \"Network Error"\ when trying to call a request
  • I've searched through the internet and they're all saying it's a network/port/ip issue, but since my phone is connected to my computer through metro and works shows that it's on the same port and network.
  • I also cannot connect to React Native Debugger despite being on the same port/network

What I have done:

  • Check IP/ports on both phone and laptop (the same)
  • Since I am on iOS, I checked if xcode is running debug build, which it is.
  • Clean rebuild, restarted phone, restarted laptop, and adding NSExceptionAllowsInsecureHTTPLoads on the Info.plist
  • Changed IP/ports


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source