How do you connect localhost in the emulator or physical device ?

Application (Android)

AndroidManifest.xml

<application
    android:networkSecurityConfig="@xml/network_security_config"
</application>


network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
	<domain-config cleartextTrafficPermitted="true">
		<domain includeSubdomains="true">IP address</domain>
	</domain-config>
</network-security-config>


Android Studio Emulator

  1. Open emulator.
  2. Click on to open Extended Controls.
  3. Go to Settings > Proxy.
  4. Uncheck Use Android Studio HTTP proxy settings.
  5. Choose Manual proxy configuration.
  6. Key in your IP address as host name and the port your backend is running on as port. (e.g. 192.168.1.86:8080)
  7. Key in the proxy authentication if enabled.
  8. Click Apply.


Physical Device (Android)

  1. Open your Android’s Settings.
  2. Tap Wi-Fi.
  3. Tap and hold the Wi-Fi Network Name.
  4. Select Modify Network.
  5. Click Advanced Options.
  6. Tap Manual.
  7. Change your proxy’s settings. Enter the hostname and proxy port. (e.g. 192.168.1.86:8080)
  8. Tap Save.


Physical Device (iPhone)

  1. Open your iPhone settings.
  2. Tap Wi-Fi.
  3. Select the info icon on the right side.
  4. Scroll down to the HTTP Proxy Configure Proxy.
  5. Tap Manual.
  6. Edit your proxy settings. (e.g. 192.168.1.86:8080)
  7. Turn on authentication if network IP is not whitelisted in the dashboard and add your Username and Password.
  8. Tap back to Wi-Fi selection window. This will save your proxy settings.