If your Kotlin app is not connecting to the internet on the Android emulator, you’re not alone. This is a common issue faced by many developers during the testing phase in Android Studio. Fortunately, the solution is straightforward once you understand the causes and know where to look.

Common Reasons the Emulator Can’t Connect
- Missing Internet Permission: Android apps need explicit permission in the manifest to access the internet.
- Wrong Network Configuration: The emulator might be running in a virtual network environment with no proper DNS or proxy.
- Incorrect API Endpoint: Using
localhost
instead of the emulator’s host IP (10.0.2.2
). - Firewall or Antivirus Restrictions: Local security software may block emulator traffic.
Step-by-Step Solution
1. Add Internet Permission
First, ensure you have added the correct permission in your AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET"/>
2. Use Correct Base URL for Emulator
When your backend server is running on your local machine, never use localhost
or 127.0.0.1
. Android emulator uses 10.0.2.2
to access your host machine.
Example Retrofit Service:
// File: ApiService.kt interface ApiService { @GET("/data") suspend fun getData(): Response<MyData> }
Retrofit Client:
// File: ApiClient.kt object ApiClient { private const val BASE_URL = "http://10.0.2.2:8080" val retrofit: Retrofit = Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build() }
3. Check Emulator Network Settings
- Go to Settings > Network & Internet on the emulator.
- Make sure airplane mode is off and the emulator has an IP address.
- If needed, restart the emulator or cold boot it from AVD Manager.
4. Check Local Server Accessibility
Ensure your local server is actually running and listening on the expected port (8080
in the above example). You can test using:
curl http://localhost:8080
Or try accessing http://10.0.2.2:8080
in the emulator browser.
5. Debug With Logs
Use Logcat
to check for UnknownHostException
, SocketTimeoutException
, or permission errors.
Final Tips
- Avoid using HTTPS without a valid certificate for local dev.
- For APIs hosted online, test with real device if possible.
- You can learn more about emulator networking in official Android docs.