I am using Android Studio 2.3(Latest). Till yesterday it was all good and working, today emulator is not connecting to the data network.
I couldn't find any solution working so far. My Mac is running on Mac OS Sierra, connected to WiFi with no proxy.
-
3Did you tried restarting it? Also, emulator loose internet connectivity when you switch from one network to another. – Deepak Singh Jun 14 '17 at 04:38
-
Yes, restarted many times, mac as well as android studio. – Amit Jun 14 '17 at 04:41
-
22021 - Google/Android unable to create an emulator that can connect to the internet – RunLoop Jul 19 '21 at 13:19
17 Answers
In Mac OS go to:
System Preferences -> Network -> select Wi-Fi os left panel -> Advanced on right panel -> DNS -> add new DNS server; for example 8.8.8.8
and 8.8.4.4
(Google Public DNS) or 1.1.1.1
and 1.0.0.1
(Cloudflare and APNIC DNS) or another public DNS provider. Then restart the emulator so the changes take effect.
Edited jun/2020
Another option is to pass dns-server params when start Android emulator.
According with this solution https://stackoverflow.com/a/51858653/3328566, I changed the emulator executable name and I created a bash script to load the AVD with param -dns-server 8.8.8.8
.
In your Android SDK default folder /Users/[MY_USER_ACCOUNT]/Library/Android/sdk/emulator/emulator
- Rename the binary
emulator
toemulator_original
- Create a bash script named
emulator
that contains:
#!/bin/bash
/Users/[MY_USER_ACCOUNT]/Library/Android/sdk/emulator/emulator_original -dns-server 8.8.8.8 $@
- Change the script permissions with
chmod +x emulator
Now, you can start AVD from Android Studio normally
In this case, you don't need to set DNS server in System Preferences. You are setting the DNS server only for the emulator, avoiding other problems

- 3,254
- 1
- 13
- 8
-
25
-
this works for me too. But I'm just scratching my head over why the heck is this happening? – Mihir Patel Dec 05 '18 at 18:41
-
6
-
1
-
6Please note that 8.8.8.8 is Google's DNS IP, if you're concerned about your own privacy, remove this line once you're done. – Skoua Feb 14 '19 at 13:27
-
3I need to agree with @Skoua. Changing your DNS to Google's public DNS is a huge scratch in your privacy purse. For now this has worked, but we need a better answer to this... – Chagall Jun 11 '19 at 01:22
-
1
-
techradar has a list of free dns servers https://www.techradar.com/au/news/best-dns-server – David Clarke Jul 30 '19 at 21:39
-
For the changes to apply you, after you click OK, you need to close System Preferences (at which point it will prompt you to save changes) – Andrew Aug 01 '19 at 14:15
-
In my case it worked only by adding both 8.8.8.8 and 8.8.4.4 to DNS servers – tudor Aug 28 '19 at 10:32
-
3I don't think this is a solution; it is merely a hack. For many people it is entirely unaccaptable or even impossible to change their local DNS settings. This may work for a developer at home who doesn't care about privacy. I suggest you go with Jez's solution. – Chrissi Oct 26 '19 at 10:12
-
It's because IPV6 is broken in Android. My ISP provides IPV6 DNS, if I disable that it works. Unlike iOS which prepared for this over a decade ago, Google still hasn't fully implemented it. – Oliver Dixon Jun 07 '20 at 12:19
-
wipe the emulator data in android studio > change 8.8.8.8 and 8.8.4.4 to DNS servers > restart emulator, it works – Mike Victoria Aug 28 '20 at 00:59
-
work fine thanks. make sure to wipe data and restart emiulator – Prabudda Fernando Nov 17 '20 at 10:10
-
If someone from M1 Chip based laptop, then pls update your android studio, that should solve the issue apart from adding the DNS. Android Studio Arctic Fox | 2020.3.1 Patch 2 Build #AI-203.7717.56.2031.7678000, built on August 27, 2021 – Sunil Kumar Sep 16 '21 at 06:44
-
I just added an alias to whole command in `.zshrc` file. `alias avd="/path/to/emulator -dns-server 8.8.8.8 -avd AVDNameHere"`. So whenever I want to open emulator i just type `avd` in terminal and it just works. – Ravi Dhoriya ツ Dec 29 '21 at 19:42
For me the issue appears to stem from the DNS settings my company enforces.
In order to be able to get network access for my emulator I needed to launch the emulator with the same corporate dns-server specified.
I'm on a Mac, so first I checked my network settings to find what my DNS was set to:
System Preferences -> Network -> Wi-Fi -> Advanced -> DNS
Then navigated to the sdk emulator location (for convenience):
cd ~/Library/Android/sdk/emulator
Then listed the available emulators:
./emulator -list-avds
Then ran the desired emulator with dns server override:
./emulator @<emulator_name> -dns-server <dns.server.ip.address>
It would be nice if I could set this DNS to be used by emulators launched through Android Studio, but hopefully these steps help someone else in a similar position.

- 1,146
- 8
- 11
-
When I run this command line ./emulator -list-avds, I do not load an emulator – dbenitobaldeon Jun 28 '19 at 15:31
-
-
@IgorGanapolsky your DNS settings are likely to be what your company computer is using. If in doubt contact your network administrator. – Jez Jul 01 '19 at 08:09
-
@dbenitobaldeon 1) ensure you've downloaded an android emulator through android studio 2) ensure that the path `~/Library/Android/sdk/emulator` does indeed point to a folder containing an `emulator` script - otherwise look up the location of your android studio emulator install directory and use that instead. The path will obviously be different if you're on a windows machine. – Jez Jul 01 '19 at 08:12
-
1In case I misunderstood your initial question @IgorGanapolsky `DNS` means "Domain Name Server", the place your computer looks to find out what IP corresponds to a website name. Eg, `google.com` might resolve to the IP address `216.58.198.174`, which is what your computer will actually use to find the website. Your DNS settings specify what server your computer will use for this service. – Jez Jul 01 '19 at 08:18
-
1@IgorGanapolsky open `System Preferences` select `Network` then `Wi-Fi` then `Advanced` then `DNS`, and you should see a pane containing a sequence of numbers, such as `8.8.8.8`. This is a DNS address. – Jez Jul 01 '19 at 21:48
i tried purge all android studio files and reinstall,
start with -dns-server,
wifi dns to 8.8.8.8,
none of them not working for me.
i found it only can using ip address in emulator.
but this post saved me.
https://www.bswen.com/2021/08/others-how-to-enable-android-emulator-internet-access.html.
1\ turn off you macos wifi;
2\ cold boot emulator;
3\ waiting the emulator's wifi connected (limited connection but it's ok)
4\ turn on you macos wifi;
it's working now.

- 331
- 3
- 3
-
1Simple and effective answer. Thanks, it helped. Still I'm wondering why did it happen. – d.aemon Jan 17 '22 at 17:59
-
1works for me too, setting new dns not works, but this is working – Farzad Farazmand Feb 07 '22 at 07:04
-
1My emulator stopped having internet connection after updating the latest emulator release (31.3.13). Your steps solved the issue. Thanks! – David Miguel Oct 31 '22 at 07:51
-
-
That worked for me as well! I had lost almost 2 hours trying other solutions, so I'm happy I came across yours – Felipe Belluco May 05 '23 at 16:57
-
I'm new to Android Studio and just ran into this issue. Network in the sim was working fine and stopped working for some reason. Didn't like any of the solutions above, so I poked around the AVD Manager and found an option to wipe the data on the sim.
- quit the sim
- open AVD Manager
- Actions > open down arrow for more options
- select Wipe Data
- restart sim

- 702
- 1
- 9
- 16
-
2Didn't expect this to work but it did, worth giving it a go before changing system-wide DNS settings. – StormFoo Oct 19 '20 at 13:52
-
1
-
2Worked perfectly the first time. Using an Apple Silicon Mac. Glad to see such a simple solution. – Rob Barber Dec 17 '21 at 19:36
Go to open AVD manager and click wipe data
That's it now the Internet will work. This is how I solved my Issue.

- 379
- 3
- 11
It's a bug with IPv6 name resolution, removing any IPv6 nameserver in /etc/resolv.confg
fixes the issue, see https://issuetracker.google.com/issues/155686508#comment3

- 865
- 8
- 8
-
This is it kind sir!! Adding Google's DNS to MacOS's system preferences didn't work. Wiping AVD data didn't work. This for me is the solution! Thanks!! – Etchelon Sep 02 '21 at 07:59
-
That's still a problem. IPv6 DNS was present in the macOS configuration, changed it to Google's default and cold rebooted it to work. – Haine Jan 16 '23 at 23:08
You can go to: System Preferences -> Network -> Wi-Fi -> Advanced -> DNS
So you add a new DNS 8.8.8.8. It might solve your problem.

- 71
- 1
- 3
-
After trying all of the ones on this page. This one did the trick. Remember to restart the simulator after setting it. – Glennweb Nov 22 '22 at 13:09
Couldn't find any solution by tweaking network settings. So added a new virtual device from Tools -> Android ->AVD Manager by downloading a new system image(Android O, API 26). And it's working now.
If you want to use the same API level then make sure to delete the existing system image and download it again.

- 3,422
- 3
- 28
- 39
If you have Blue Coat Unified Agent, internet wont work. Kindly uninstall it.
It can be uninstalled by going to below folder- /Library/Application Support/bcua

- 31
- 1
None of the answers worked for me on a m1 mac, I was not even able to connect to localhost for the react-native development server.
The trick for me was to turn off the cellular data "T-mobile," then it would use AndroidWiFi for internet and everything worked fine.

- 6,105
- 3
- 38
- 35
-
-
2this isn't working for me... I have m1 mac and I tried turnning off mobile – AJay Dec 13 '22 at 05:24
I was facing the same issue but when I followed below step it was resolved. System preferences-> Network-> Ethernet/WiFi->Advance->DNS->Add->8.8.8.8-> Add->8.8.4.4 and then click on OK and apply the changes and then Cold boot the android emulator from AVD manager/device manager.
-
Any idea why this works? What's the significance behind 8.8.8.8 and 8.8.4.4? – Leland Reardon May 28 '23 at 12:42
If you don't find the DNS in the System Preferences -> Network -> Wi-Fi -> Advanced, you can just search for DNS in the Search bar on Mac

- 11
- 1
- Click Apple menu > System Preferences > Network.
- Click Advanced.
- Select the DNS tab.
- Add 8.8.8.8 and 8.8.4.4
- Click OK > Apply.
- Restart AVDs.

- 1,050
- 1
- 14
- 38
Easiest fix is to plug in a LAN cable in your laptop/computer. No messing around with the DNS settings needed.

- 320
- 3
- 18
There was an update available to my Android Studio, i updated it and it worked!

- 378
- 1
- 5
- 15
if its an android project, u can change the baseUrl to 10.0.2.2, note this is only applicable from android emulator, will not work on phone
e.g Api endpoint will now look like this: val baseUri : String = "http://10.0.2.2/restapi/"
val loginEndpoint = "${baseUri}login"

- 15
- 2
-
I wonder in what scenario this might work. Does the url `10.0.2.2` replace `localhost`? In any way, this is not an answer to connect to the internet, but only to your api. – Randy Aug 12 '20 at 08:43