1

I am trying to connect to a remote database in this case "localhost" in android for some reason I am geting an error saying that Connection to http://localhost refused . i am not sure what is causing this , but my guess is it is this line below

response = CustomHttpClient.executeHttpPost("http://localhost/check.php", postParameters);
                String res=response.toString();
               // res = res.trim();
                res= res.replaceAll("\\s+","");                              
                //error.setText(res);

               if(res.equals("1"))
                    error.setText("Correct Username or Password");
                else
                    error.setText("Sorry!! Incorrect Username or Password"); 
            } catch (Exception e) {
                error.setText(e.getMessage());
            }

        }
    });

enter image description here

Thanks for any help

sam
  • 131
  • 1
  • 4
  • 11

1 Answers1

1

You're not running a webserver on your android instance; the Android emulator is running on a virtual machine on your development machine. Try using the literal IP address of your development machine.

Paul Sonier
  • 38,903
  • 3
  • 77
  • 117