title: Alamofire Request error: NSURLErrorDomain Code -1005 The network connection was lost
body: <p>I'm working on transferring my project from AFNetworking to Alamofire. Really like the project. However, I'm receiving this error when attempting to make a GET request.</p>
  
  <p>Here's some example code:</p>
  
  <pre><code>class func listCloudCredntials(onlyNew onlyNew: Bool = true, includePending: Bool = true) -&gt; Request {
  
      let parameters: [String: AnyObject] = includePending ? ["include_pending": "true"] : [:]
  
      let urlString = "https://myapp-staging.herokuapp.com/api/1/credntials"
  
      let token = SSKeychain.storedToken()
  
      let headers: [String: String] = ["Authorization": "Bearer \(token)"]
  
      return Alamofire.request(.GET, urlString, parameters: parameters, encoding: .JSON, headers: headers)
  }
  </code></pre>
  
  <p>Then, in my VC:</p>
  
  <pre><code>listCloudCredntials().validate().responseJSON() {
      (response: Response&lt;AnyObject, NSError&gt;) in
  
      switch response.result {
      case .Success(let result):
          printCR("success: \(result)")
  
      case .Failure(let error):
          printCR("error: \(error)")
      }
  }
  </code></pre>
  
  <p>Here's the error I'm running into:</p>
  
  <blockquote>
    <p>Error Domain=NSURLErrorDomain Code=-1005 "The network connection was
    lost." UserInfo={NSUnderlyingError=0x14e9c77f0 {Error
    Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)"
    UserInfo={_kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}},
    NSErrorFailingURLStringKey=<a href="https://myapp-staging.herokuapp.com/api/1/credntials">https://myapp-staging.herokuapp.com/api/1/credntials</a>,
    NSErrorFailingURLKey=<a href="https://myapp-staging.herokuapp.com/api/1/credntials">https://myapp-staging.herokuapp.com/api/1/credntials</a>,
    _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-4, NSLocalizedDescription=The network connection was lost.}</p>
  </blockquote>
  
  <p>I've tried running on the iOS Simulator with 1OS 8.4 and iOS 9.1, as well as my iPhone 6S running iOS 9.1.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>--------<strong>EDIT</strong>--------</p>
  
  <p><strong>To clarify, this function works just fine with AFNetworking.</strong></p>
  
  <p>Here's the debugprint(request) result (it's a GET request):</p>
  
  <pre><code>$ curl -i \
  -H "Authorization: Bearer some-JWT-Security-Token" \
  -H "Content-Type: application/json" \
  -H "Accept-Language: en-US;q=1.0" \
  -H "Accept-Encoding: gzip;q=1.0,compress;q=0.5" \
  -H "User-Agent: Company/com.Company.AppName (1081; OS Version 9.2 (Build 13C75))" \
  -d "{\"include_pending\":\"true\"}" \
  "https://appname-staging.herokuapp.com/api/1/credntials"
  </code></pre>
  
  <p>I have to change curl -i to curl -X GET in order for the curl to return successfully.</p>
  
  <p>Here is another call that I'm required to make in the app that works with no issues.</p>
  
  <pre><code>curl -i \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Accept-Language: en-US;q=1.0" \
  -H "Accept-Encoding: gzip;q=1.0,compress;q=0.5" \
  -H "User-Agent: Company/com.Company.AppName (1081; OS Version 9.2 (Build 13C75))" \
  -d "{\"token\":\"UserSessionTokenString\"}" \
  "https://appname-staging.herokuapp.com/api/1/authenticate/user"
  </code></pre>
  
  <p>Could it be something with the GET vs. POST?</p>