How To Connect To A Http Server Running In Android Emulator From PC Vice Versa

Sometimes you need connect to local web server running in your PC from android emulator. And sometimes you need use PC web browser to browse web pages stored in web server running in android emulator. These two scenario are commonly use case when you develop android application. This article will tell you how to implement.

1. Connect To Web Server Running On PC From Android Emulator.

  1. Install a web server such as tomcat in your PC. You can read article How To Install Tomcat 9.0 Correctly On Your Machine and How To Install Tomcat In MacOS.
  2. After installation start tomcat server from command line.
  3. Open a web browser in android emulator and input in url address text box. is an alias ip to access the PC where android emulator execute in. 8089 is the tomcat server listening port number.
    browse web page from android emulator

2. Connect Web Server Running On Android Emulator From Local PC.

  1. Suppose the web server listening on port number 8090 in android emulator, and you want to access that web server from the emulator hosted PC web browser, you should do followings.
  2. Get android SDK location. You can open android studio, click File —> Project Structure  menu item in the top tool bar. Then you can find the android SDK location in the popup dialog.
    android studio file project structure
    android sdk location folder in android studio
  3. Open a terminal or dos window, and go to platform-tools directory under above android SDK location directory. Then run below command to forward http tcp request to local PC port 8090 to android emulator port 8090.
    adb forward tcp:8090 tcp:8090
  4. Now you can open web browser and browse web pages hosted in android emulator web server from your PC.
0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x