IOS Can't assign requested address, errno = 49

We've run into some HTTP request errors, details as follows:

  1. We're currently at a loss because restarting the app doesn't help, only rebooting the phone restores things to normal.
  2. Based on tracking data, the occurrence rate for users is about 0.033%, and it's only happening on iOS, Android is fine.
  3. iOS operating system versions: 14-27 are all affected.
  4. The same issue appears in Rust, Flutter, and C/C++.

Rust: 2026-07-11-19:39:22.252+0800|F4E26069-2D7E-4D5F-8B53-664E012B2CA7|UPLogDefaultLogger|DEBUG|测试模式|1023629905|[userdomain_rust/rust_userdomain/src/operator/device_ops/refresh_device_list_op.rs:61]query_device_list error: HttpRequstFaild(Reqwest(reqwest::Error { kind: Request, url: "https://zj.haier.net/api-gw/wisdomdevice/device/v11/family/devices?familyId=ALL&filterFlag=false", source: hyper_util::client::legacy::Error(Connect, ConnectError("tcp connect error", 36.156.179.34:443, Os { code: 49, kind: AddrNotAvailable, message: "Can't assign requested address" })) }))

Flutter: 2026-07-11-15:29:02.718371+0800|b2257ae8-f7d8-41d0-8811-2ff1824f95d9|UpPlugins|ERROR|正常模式|1023629905|level:error tag:smart_home msg:getWholeHousePreferenceSetting err: DioException [unknown]: null Error: SocketException: Connection failed (OS Error: Can't assign requested address, errno = 49), address = zj.haier.net, port = 443

C/C++: 2026-07-11-19:39:15.247588+0800|a991af96-bf02-4b94-a437-d4f7efc249ff|uSDK|ERROR|正常模式|1023629905|[CAE][[cae_sock_no_ssl_last_err:869][connect fd 122 ret -1 err 49: Can't assign requested address] ]

  1. Native iOS HTTP interface requests work fine, for example when using AFNetworking.

Looking for your help~

Answered by DTS Engineer in 899092022
Native iOS HTTP interface requests work fine

Cool. Thanks for testing that.

You’re using a variety third-party libraries which are likely layered on top of BSD Sockets. Error 49 is EADDRNOTAVAIL, which I usually see when folks are doing weird things things sockets, like UDP. However, in this case you’re making an outgoing TCP connection, and it’s hard to get that error with an outgoing TCP connection when you use BSD Sockets correctly.

Specifically, when making an outgoing TCP connection you should not bind the socket to an address, that is, don’t call bind. This lets the networking stack choose the correct local address based on your destination address.

There are a couple of steps you could take to investigate this:

  1. You could create a small test project that uses BSD Sockets correctly and see if it has the same problem. If so, that’s something that I can take a look at.
  2. If it doesn’t, then you’ll need to dig into your third-party libraries to determine the exact sequence of BSD Sockets calls they’re making.

Finally:

  • If you prefer working in Swift, you’ll find that calling BSD Sockets directly is a bit of a pain. I have a trivial wrapper that can help with that; see Calling BSD Sockets from Swift. It’s not meant for production code, but it’s great for a test project.
  • For advice on how to use BSD Sockets correctly — in general, but of specific importance on Apple platforms — see BSD Sockets best practices in TN3151 Choosing the right networking API.

Share and Enjoy

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

Native iOS HTTP interface requests work fine

Cool. Thanks for testing that.

You’re using a variety third-party libraries which are likely layered on top of BSD Sockets. Error 49 is EADDRNOTAVAIL, which I usually see when folks are doing weird things things sockets, like UDP. However, in this case you’re making an outgoing TCP connection, and it’s hard to get that error with an outgoing TCP connection when you use BSD Sockets correctly.

Specifically, when making an outgoing TCP connection you should not bind the socket to an address, that is, don’t call bind. This lets the networking stack choose the correct local address based on your destination address.

There are a couple of steps you could take to investigate this:

  1. You could create a small test project that uses BSD Sockets correctly and see if it has the same problem. If so, that’s something that I can take a look at.
  2. If it doesn’t, then you’ll need to dig into your third-party libraries to determine the exact sequence of BSD Sockets calls they’re making.

Finally:

  • If you prefer working in Swift, you’ll find that calling BSD Sockets directly is a bit of a pain. I have a trivial wrapper that can help with that; see Calling BSD Sockets from Swift. It’s not meant for production code, but it’s great for a test project.
  • For advice on how to use BSD Sockets correctly — in general, but of specific importance on Apple platforms — see BSD Sockets best practices in TN3151 Choosing the right networking API.

Share and Enjoy

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

We don't operate BSD Sockets directly; instead, we use third-party libraries, such as reqwest in Rust and dio in Flutter. Of course, these third-party libraries definitely use BSD Sockets at the底 layer. The issue is that these third-party libraries should be stable, so such TCP connection problems shouldn't occur on a large scale. Therefore, please analyze and see if there is a better solution.Looking forward to your reply, much appreciated

So, my group here at Apple, DTS, is primarily focused on helping third-party developers with Apple tools and APIs. We don’t support third-party stuff. If your third-party stuff is giving you problems, you have a choice:

  • You can hope that someone else with relevant experience chimes in here.
  • You can seek help from the vendor.
  • You can file a bug for Apple’s engineering teams to look at.
  • If you’re working with something that’s open source, you can dig into the problem yourself, work out if there’s an issue with an Apple API, and then seek my help here.

My experience is that last option is the best path forward, and hence my advice above, but the choice is really up to you.

Share and Enjoy

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

IOS Can't assign requested address, errno = 49
 
 
Q