Android 127.0.0.1/localhost connection refused

Source: Internet
Author: User

In debugging, connect localhost or 127.0.0.1 through the android simulator.CodeProbably
URL url = new URL (urlstring );
Urlconnection urlconn = URL. openconnection ();

But an error is reported !!

Exception 1: java.net. connectexception: localhost/FIG: 8080-
Connection refused

 

 

The problem is that the android simulator uses itself as the localhost. That is to say, it uses localhost or 127.0.0.1 in the code to access the simulator itself! This cannot be done!

If you want to access your computer on the simulator, use the built-in Android IP address.10.0.2.210.0.2.2 is the specific IP address set by the simulator. It is the alias of your computer alias.

Access your computer using 10.0.2.2 on the simulator

 

 

From: http://80x86.javaeye.com/blog/539356

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.