简体   繁体   中英

Android emulator can no longer connect to localhost

I have a server on my computer running on localhost:8080 , previously I was able to access this in the Android emulator under 10.0.2.2:8080 and it worked great. I went to load it again at some point today and it no longer works. No configuration has changed to my knowledge.

I can still access localhost when I use a browser on my computer, so the server is still running okay. But on the emulator, whether using my app or a browser it will not connect.

Any suggestions would be appreciated. Thanks.

In case anyone comes across this in a search, this is how I fixed the problem:

  1. Open terminal and enter sudo nano /private/etc/hosts
  2. Delete the line ::1 localhost
  3. Ctrl-O then enter to save. Ctrl-X to exit.

Restarted my local server and after that it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM