Error al conectar con localhost
<p>Could you help me with my problem?</p>

<p>I am trying to access localhost to obtain the data from a table but I get an error <strong>HttpHostConnectException</strong> when i run it </p>

<p>COMPLETE ERROR: org.apache.http.conn.HttpHostConnectException: Connection to <a href="http://localhost" rel="nofollow">http://localhost</a> refused</p>

<p>Code used:</p>

<pre><code>public class MysqlConnectActivity extends Activity {
private TextView tv;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    tv = (TextView) findViewById(R.id.TextView01);
}

private class DownloadPoints extends AsyncTask&lt;String, Void, String&gt; {
    @Override
    protected String doInBackground(String... urls) {
        String response = "";

        try {
            HttpClient client = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://localhost/leerDatosUsuarios.php");
            HttpResponse execute = client.execute(httppost);
            InputStream content = execute.getEntity().getContent();

            BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
            String s = "";
            while ((s = buffer.readLine()) != null) {
                response += s;
            }

        } 
        catch (Exception e) {
            Log.e("log_tag", "Error en la conexion HTTP: "+e.toString());
        }

        return response;
    }

    @Override
    protected void onPostExecute(String result) {
        tv.append("\nREAD FROM MYSQL:\n" + result);
    }
}

public void readWebpage(View view) {
    DownloadPoints task = new DownloadPoints();
    task.execute( "http://localhost/leerDatosUsuarios.php");

}
</code></pre>

<p>Thank you for your attention
Alvaro</p>
