My app suddenly getting "A server with the specified hostname could not be found"

I've had no problem running my app in a simulator or on a device, but today my app is failing on a URLRequest to my local machine (in a sim). From the same simulator I can go to Safari and manually enter the URL that the app is using (and that appears in the error message), and it works fine.

I think there was a recent Xcode update; did something change in this regard?

Answered by DTS Engineer in 837424022

So that other thread you mentioned only affects the iOS 18.4 simulator. Given that you’re seeing this in the iOS 18.2 simulator, something else is afoot.

Earlier you wrote:

my app is failing on a URLRequest to my local machine (in a sim).

I want to confirm my understanding of “local machine”. Specifically, if you run your app on a real device, does this request trigger the local network alert? See TN3179 Understanding local network privacy for more about this.

If so, I suspect you might be hitting a different issue, the one discussed in this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

When version of the simulator are you running in? Specifically, if you’re running in the iOS 18.4 simulator, I’d like you to try again in the iOS 18.3 simulator.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the follow-up. I'm running in an 18.2 simulator (iPhone 16).

Someone pointed me to the related thread here, where I replied. The suggested workaround (suppressing HTTP 3 for the simulator) did not work for me.

So that other thread you mentioned only affects the iOS 18.4 simulator. Given that you’re seeing this in the iOS 18.2 simulator, something else is afoot.

Earlier you wrote:

my app is failing on a URLRequest to my local machine (in a sim).

I want to confirm my understanding of “local machine”. Specifically, if you run your app on a real device, does this request trigger the local network alert? See TN3179 Understanding local network privacy for more about this.

If so, I suspect you might be hitting a different issue, the one discussed in this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks. The problem does not occur if I run on a device connected by USB to the local (development) machine.

In both cases, my application is hitting an HTTP server running on my Mac, using the Mac's hostname. This previously worked in the same simulator without a problem. A can hit the same endpoints in the simulator's Safari, no problem. It's only the URLRequests in my app that fail (again only in the sim).

I was surprised that my phone could hit my Mac despite not being on Wi-Fi... apparently it's using the USB connection for networking. I do have my own certificates deployed to the simulator and phone.

Thanks for the link to the other problem, but I'm not seeing "PolicyDenied" in any of the error output.

I'm not seeing "PolicyDenied" in any of the error output.

Right. But that bug affects all DNS, not just Bonjour. So, due to this bug, local network privacy is blocking the DNS query made by URLSession, and hence this error.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

OK, thanks for the info!

My app suddenly getting "A server with the specified hostname could not be found"
 
 
Q