Request Timed out with Code=-1001_kCFStreamErrorCodeKey=-2102

Sometimes network request from my app gets stuck. And I get following error after a while,

failed with error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x1390937f0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=https:/

Any request I make after this, The same sent request is sent out and it fails with same error. So, no new request goes out. This happens very rarely, but it does happen.

I am using NSURLSessionDataTask:dataTaskWithRequest:completionHandler to make a network calls.

Post not yet marked as solved Up vote post of nimishm Down vote post of nimishm


Both of these error codes are time out errors (in

, -1001 is
/ -2102 is a not in the public headers but it’s effectively the same thing).

It’s hard to say what’s going on here without more information. To start, you should try to capture a packet trace and a CFNetwork diagnostics log of the problem occurring.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + ""

Thanks Eskimo. I wil try using charles to see the packet trace. But I doubt I will find anything there as I don't see any trace of the request on server. So, I guess request is dying in the device itself.

I wil try using charles to see the packet trace.

Charles is a good tool for debugging HTTP-level issues but it’s not the right tool for this job because:

  • it requires you to configure a proxy, which changes how the traffic works on the wire

  • it doesn’t let you see anything about the internal state of CFNetwork

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + ""

Did you find the cause of the problem? I'm having a report on my application of the same issue.

i was searching for this issue, and seems like i can't find much logs for my timeout apis.
logging cfnetworks gives me timeout log for the same requests.

CFNetwork Diagnostics [3:1352] 03:27:20.761 {
       Did Timeout: (null)
            Loader: <CFURLRequest 0x6080001bcc40 [0x113ef4df0]> {url =, cs = 0x0}
  Timeout Interval: 60.000 seconds
init to origin load: 0.00235498s
        total time: 60.0667s
       total bytes: 0 is a dummy for my domain.
all the request going to <> is working fine.

but if i make a reuqest to <> , i most of the time get timeout while is always working.

At this time, if i use the same url and run it on safari on my device. it works fine.

Dont really understand what is causing this.

To make progress here you’re going to need to correlate the info in the CFNetwork diagnostics log with the on-the-wire info from a packet trace. There’s references to both in my first response on this thread.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + ""

Hi, I have same issue. I have CFNetwork diagnostic files and Wireshark dump.
In wireshark there are no network request (not tcp syn/ack, not any line for it).

Diagnostic log:

I see only this data for that request.
Every else request to another domain or to same domain, but HTTP is OK.

Everything works good after kill of app and run it again.

I can repeat this bug on iOS Simulator iPhone 7, 10.3.1: I am running my app, everything is OK. Then, I close app (by home button) and wait 10-20min and run it from dashboard. After app become active, it starts refresh their data and show me timeout error 😟

Update: finally I have fixed issue. During refactoring of deprecated API of NSURLConnection we replace

-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

-(void)connection:(NSURLConnection *)connection didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

By incorrect version of

-(void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

But, after refactoring everything was OK. We found the existence of bug onle 4 months later. It appears only after app go background and 10-15min late go foreground. System calls this method and pause all https requests to current domain.

Hi there,

I have an app calling https json web service that runs perfectly while in foreground, but as soon as the app hit the store some clients started to complain, saying their apps stopped calling the web service when changed from background to foreground. I cannot replicate this on the simulator, and in the time the phone needs to be in background before the problem arises is usually between 10 - 45 minutes, but sometimes I can catch this situation in under 30 seconds.

I'm using URLSession, with URLSessionConfiguration.ephemeral, and when the app stops calling https I usually have these errors:

2018-03-07 14:19:39.729144+0000 ***[970:276549] dnssd_clientstub read_all(6) DEFUNCT

2018-03-07 14:19:39.729220+0000 ***[970:276549] [] nw_resolver_create_dns_service_locked DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)


2018-03-07 11:18:27.055764+0000 ***[845:212540] [] tcp_timers tcp[158] retransmit SYN 3

2018-03-07 11:18:27.089724+0000 ***[845:212540] [] tcp_timers tcp[158] retransmit SYN 4

2018-03-07 11:18:27.124971+0000 ***[845:212540] [] tcp_timers tcp[158] retransmit SYN 5

2018-03-07 11:18:27.189602+0000 ***[845:212540] [] tcp_timers tcp[158] retransmit SYN 6

2018-03-07 11:18:27.315243+0000 ***[845:212540] [] tcp_timers tcp[158] retransmit SYN 7

2018-03-07 11:18:27.562810+0000 ***[845:212540] [] tcp_timers tcp[158] retransmit SYN 8

2018-03-07 11:18:28.045921+0000 ***[845:212540] [] tcp_timers tcp[158] retransmit SYN 9

2018-03-07 11:18:29.011447+0000 ***[845:212541] [] tcp_timers tcp[158] retransmit SYN 10

### app did enter background ###

2018-03-07 11:18:33.380964+0000 ***[845:212540] TIC TCP Conn Failed [155:0x1c03747c0]: 1:50 Err(50)

2018-03-07 11:18:33.680429+0000 ***[845:212540] Task <50BAB428-A595-4EEF-ABCA-70D089E5B8FE>.<1> HTTP load failed (error code: -1009 [1:50])

### app will enter foreground ###

2018-03-07 11:18:33.682984+0000 WHS Live 3[845:212552] Task <50BAB428-A595-4EEF-ABCA-70D089E5B8FE>.<1> finished with error - code: -1009


2018-03-05 15:36:14.627231+0000 WXXX[2012:881112] dnssd_clientstub read_all(6) DEFUNCT

2018-03-05 15:36:14.627333+0000 ***[2012:881112] [] nw_resolver_create_dns_service_locked DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)

2018-03-05 15:36:14.631977+0000 ***[2012:881112] TIC TCP Conn Failed [44:0x1c4362100]: 10:-72000 Err(-65563)

2018-03-05 15:36:14.646173+0000 ***[2012:881497] Task <6E77DC57-DF21-4074-A722-D34530071C48>.<1> HTTP load failed (error code: -1003 [10:-72000])

2018-03-05 15:36:14.649336+0000 ***[2012:880659] Task <6E77DC57-DF21-4074-A722-D34530071C48>.<1> finished with error - code: -1003

Any idea is this might be a similar issue?

Thank you in advance.



Am also facing the same issue is there any solution for that

Seeing your TCP SYN retransmissions reminded me of something I encountered a few months ago.

In my case the problem had to do with users who were on IPv6-only cellular data connections. These are becoming increasingly common. Maybe that's what's going on. I'm short on details, but perhaps that can get some people pointed down the right path.