title: HTTP Exception :: Failed to connect to any resolved endpoint - cpprestsdk
body: <p>I'm trying to use <a href="https://github.com/Microsoft/cpprestsdk" rel="nofollow noreferrer"><strong>Microsoft's cpprestsdk</strong></a>, but I'm getting this error : </p>
  
  <blockquote>
    <p>HTTP Exception :: Failed to connect to any resolved endpoint Code ::
    101</p>
  </blockquote>
  
  <p>Here is my code :</p>
  
  <pre><code>#include &lt;cpprest/http_client.h&gt;
  #include &lt;cpprest/filestream.h&gt;
  
  using namespace utility;                    // Common utilities like string conversions
  using namespace web;                        // Common features like URIs.
  using namespace web::http;                  // Common HTTP functionality
  using namespace web::http::client;          // HTTP client features
  using namespace concurrency::streams;       // Asynchronous streams
  
  int main(int argc, char* argv[])
  {
      auto fileStream = std::make_shared&lt;ostream&gt;();
  
      // Open stream to output file.
      pplx::task&lt;void&gt; requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile)
      {
          *fileStream = outFile;
  
          // Create http_client to send the request.
          http_client client(U("http://www.bing.com/"));
  
          // Build request URI and start the request.
          uri_builder builder(U("search"));
          builder.append_query(U("q"), U("cpprestsdk github"));
          return client.request(methods::GET, builder.to_string());
      })
  
      // Handle response headers arriving.
      .then([=](http_response response)
      {
          printf("Received response status code:%u\n", response.status_code());
  
          // Write response body into the file.
          return response.body().read_to_end(fileStream-&gt;streambuf());
      })
  
      // Close the file stream.
      .then([=](size_t)
      {
          return fileStream-&gt;close();
      });
  
      // Wait for all the outstanding I/O to complete and handle any exceptions
      try
      {
          requestTask.wait();
      }
      catch (web::http::http_exception &amp;e)
      {
          printf("HTTP Exception :: %s\nCode :: %d\n", e.what(), e.error_code());
      }
      catch (const std::exception &amp;e)
      {
          printf("Error exception:%s\n", e.what());
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Source : <a href="https://github.com/Microsoft/cpprestsdk/wiki/Getting-Started-Tutorial" rel="nofollow noreferrer">https://github.com/Microsoft/cpprestsdk/wiki/Getting-Started-Tutorial</a></p>
  
  <p>And I used this </p>
  
  <pre><code>g++ -std=c++11 my_file.cpp -o my_file -lboost_system -lcrypto -lssl -lcpprest
  ./my_file
  </code></pre>
  
  <p>to build my code.
  But I'm getting an error code of 101. What is going wrong?</p>