Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7683581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:49:37+00:00 2026-05-31T18:49:37+00:00

Could you help me with my problem? I am trying to access localhost to

  • 0

Could you help me with my problem?

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

COMPLETE ERROR: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused

Code used:

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<String, Void, String> {
    @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");

}

Thank you for your attention
Alvaro

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:49:38+00:00Added an answer on May 31, 2026 at 6:49 pm

    Localhost is your actual android device.

    If you are trying to access your development machine, you need to access 10.0.2.2 from the emulator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

could someone help me on this problem, i want to access facebook API through
I wonder if anyone could help me with a problem I've been having. I
I recently ran into a problem that I thought boost::lambda or boost::phoenix could help
Do you think jquery could help me get the following script work faster? Thanks!
I am having this problem An error occurred while trying to make a request
I'm trying to automate a tedious problem. I get large Excel (.xls or .csv,
i'm trying to access alarm provider to get all enabled alarm information. so i
I am trying to help a small business that has an application that could
I've a litle big problem with java heap memory I'm trying to migrate from
I wonder if any of you could help with this problem. The following code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.