NSURLSessionTask fails with "No such file or directory"

Originator:nikolai.ruhe
Number:rdar://23048120 Date Originated:09-Oct-2015
Status:Open Resolved:
Product:iOS Product Version:9.0
Classification: Reproducible:Always
 
When using NSURLSession to access localhost by using its IP address (i.e. "http://192.168.1.3/") the task fails with NSPOSIXErrorDomain, Code=2 "No such file or directory".

For the error to happen, the following must be true:
- The host on the URL must be the current machines IP address. Using "localhost" or "127.0.0.1" works as expected.
- The host must actually serve the URL at the given port.
- ATS has to be off for the app.

This error is introduced in the SDK iOS 9.

Steps to Reproduce:
1. Start some http server on the development machine.
2. Open the attached example project.
3. Fill in the correct IP address (from ifconfig or the network system configuration)
4. Run the demo app in the simulator.

Expected Results:
No error.

Actual Results:
Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"

Version:
iOS SDK 9.0

Notes:


Configuration:
Xcode 7.0.1, Mac OS 10.11

Comments

Seeing this as well. Oddly enough, using a physical device works fine. It's just the simulator that has issues.

By mikehartington at Oct. 22, 2015, 5:07 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!