title: Always receive org.apache.http.NoHttpResponseException: The target server failed to respond Android
body: <p>I am working on HTTP post in android. Here is my code:</p>
  
  <pre><code> SendMail sending = (SendMail) new SendMail()
                                  .execute(url + "/mob/android/dummy.php");
  
  
      public class SendMail extends AsyncTask&lt;String, String, String&gt; {
  
      private String endResult;
  
      @Override
      protected String doInBackground(String... val) {
          String url = val[0];
          Log.i("Url", url + "");
  
          HttpClient httpclient = new DefaultHttpClient();
  
          HttpPost httppost = new HttpPost(url);
  
          try {
  
              CookieStore cookieStore = new BasicCookieStore();
              ((AbstractHttpClient) httpclient).setCookieStore(cookieStore);
  
              List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
              nameValuePairs.add(new BasicNameValuePair("name", post_name));
              nameValuePairs
  
  
              nameValuePairs.add(new BasicNameValuePair("email", post_email));
              nameValuePairs.add(new BasicNameValuePair("message",
                      "Requesting appointment from: " + SelectedDr
                              + "  Message: " + post_message));
  
              Log.i("nameValuePairs:", "" + nameValuePairs);
  
              httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
              HttpResponse response = httpclient.execute(httppost);
              BasicResponseHandler myHandler = new BasicResponseHandler();
              endResult = myHandler.handleResponse(response);
              Log.i("nameValuePairs", "" + nameValuePairs);
              Log.i("endResult", "" + endResult);
          } catch (ClientProtocolException e) {
  
          } catch (IOException e) {
  
          }
  
          return null;
      }
  
      @Override
      protected void onPostExecute(String result) {
  
          super.onPostExecute(result);
          publishProgress(endResult);
  
      }
  
      @Override
      protected void onProgressUpdate(String... values) {
  
          super.onProgressUpdate(values);
          String result = values[0];
  
          T_warning.setText("Mail Sent.");
          ET_email.setText("");
          ET_name.setText("");
  
          ET_message.setText("");
  
  
  
  
  
      }
  
  }
  </code></pre>
  
  <p>Now till </p>
  
  <pre><code>nameValuePairs.add(new BasicNameValuePair("message",
                  "Requesting appointment from: " + SelectedDr
                          + "  Message: " + post_message));
  </code></pre>
  
  <p>it is working fine but on HttpResponse response = httpclient.execute(httppost); it gives no reponse after 3 minutes it gives mail sent but on my mail server I received no mail and also show exception:</p>
  
  <blockquote>
    <p>org.apache.http.NoHttpResponseException: The target server failed to respond</p>
  </blockquote>
  
  <p>I am stuck with that I could not understand why this is happening I added all permissions</p>
  
  <p>LOGCAT:</p>
  
  <pre><code>04-05 10:41:57.110: I/exception(3926): org.apache.http.NoHttpResponseException: The target server failed to respond
  
  04-05 10:41:57.110: I/endResult(3926): null
  </code></pre>
  
  <p><strong>Edited Code gives LOGCAT:</strong></p>
  
  <pre><code>04-05 10:51:17.160: W/System.err(4016): org.apache.http.NoHttpResponseException: The target server failed to respond
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:85)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:653)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
  
  04-05 10:51:17.170: W/System.err(4016):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
  
  04-05 10:51:17.170: W/System.err(4016):     at com.ilmasoft.alina_dental.MailUs$SendMail.doInBackground(MailUs.java:492)
  
  04-05 10:51:17.180: W/System.err(4016):     at com.ilmasoft.alina_dental.MailUs$SendMail.doInBackground(MailUs.java:1)
  
  04-05 10:51:17.180: W/System.err(4016):     at android.os.AsyncTask$2.call(AsyncTask.java:252)
  
  04-05 10:51:17.180: W/System.err(4016):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  
  04-05 10:51:17.180: W/System.err(4016):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  
  04-05 10:51:17.180: W/System.err(4016):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
  
  04-05 10:51:17.180: W/System.err(4016):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
  
  04-05 10:51:17.180: W/System.err(4016):     at java.lang.Thread.run(Thread.java:1020)
  </code></pre>