title: curl_easy_perform() failed: Couldn't connect to server
body: <p>So I am using libcurl with C++ to retreive the data in a page, but for some reason it throws the error in the post title when I connect to my vps. The code in the vps just makes a get request and spits out some data from my database. </p>
  
  <pre><code>#include "requestMapper.hpp"
  
  // Send a GET request to API to retreive image
  void RequestMapper::retreiveData(std::string url) {
      CURL *curl;
      CURLcode res;
  
      curl_global_init(CURL_GLOBAL_DEFAULT);
      curl = curl_easy_init();
      if(curl) {
          ISSUE HERE // curl_easy_setopt(curl, CURLOPT_URL, "https://104.236.200.91/index.php/food/");
          res = curl_easy_perform(curl);
  #ifdef SKIP_PEER_VERIFICATION
          curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
  #endif
  #ifdef SKIP_HOSTNAME_VERIFICATION
          curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
  #endif
          res = curl_easy_perform(curl);
          if (res != CURLE_OK)
              fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
          curl_easy_cleanup(curl);
      }
      curl_global_cleanup();
  }
  
  // Submit a post request to API link to send data
  void RequestMapper::postData() {
  
  }
  
  
  int main(void) {
      RequestMapper rm;
      rm.retreiveData("sample");
      return 0;
  }
  </code></pre>
  
  <p>This code is working fine when the url is something like "<a href="https://google.com" rel="nofollow noreferrer">https://google.com</a>" but when I hit the link to my web server I set up I get that error. I am newer to this library, but I thought I was doing things correctly. if anyone has any insight please let me know! I'll continue to tinker with this and if I find a solution I'll share it here.</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I recently solved this issue and wanted to share it with anyone who might stumble upon this post. 
  I was using <code>https://URL</code> when instead I should have been using <code>http://URL</code> so if you run into this issue try using that instead first!</p>