org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused in android

后端 未结 13 1706
一向
一向 2020-12-02 20:42

I am making an application that uploads images to server and updates its database to server in android while executing it, it shows an error

Connection to ht         


        
相关标签:
13条回答
  • 2020-12-02 21:01
    http://localhost
    

    The above host is already occupied by the emulator in which you are running the code. If you want to access the local host of your computer than use the IP Address as http://10.0.2.2:8080/.

    For more details, please refer this link.

    0 讨论(0)
  • 2020-12-02 21:05

    <uses-permission android:name="android.permission.INTERNET"/> add this tag above into AndroidManifest.xml of your Android project ,and it will be ok.

    0 讨论(0)
  • Please check that you are running the android device over same network. This will solve the problem. have fun!!!

    0 讨论(0)
  • 2020-12-02 21:06

    One of the basic and simple thing which leads to this error is: No Internet Connection

    Turn on the Internet Connection of your device first.

    (May be we'll forget to do so)

    0 讨论(0)
  • 2020-12-02 21:06

    use 127.0.0.1 instead of localhost

    0 讨论(0)
  • 2020-12-02 21:09

    for wamp server use 10.0.2.2 for local host e.g. 10.0.2.2/phpMyAdmin

    and for tomcat use 10.0.2.2:8080/server

    0 讨论(0)
提交回复
热议问题