Handling Errors

Handle errors resulting from StoreKit requests.


A StoreKit request may fail for one of many possible reasons, including invalid product information, invalid payment details, problems with your App Store Connect account, or networking issues. When an error occurs, check the error code to find out what went wrong.

Determine the Cause of the Error

When handling errors, such as with the request(_:didFailWithError:) delegate method, it is important to use the domain and code of the resulting error to determine the underlying cause of failure.

StoreKit uses the SKErrorDomain error domain for errors related to payments, store products, and cloud services, as described in SKError.Code. For additional information on troubleshooting StoreKit framework issues, see the In-App Purchase FAQ.

Errors related to networking use the NSURLErrorDomain error domain. The following table describes some of the most common networking errors that may occur when using StoreKit.

Table 1

Common NSURLErrorDomain errors when using StoreKit

Error code


NSURLErrorTimedOut (-1001)

The connection timed out.

NSURLErrorCannotFindHost (-1003)

The connection failed because the host could not be found.

NSURLErrorCannotConnectToHost (-1004)

The connection failed because a connection cannot be made to the host.

NSURLErrorNetworkConnectionLost (-1005)

The connection failed because the network connection was lost.

NSURLErrorNotConnectedToInternet (-1009)

The connection failed because the device is not connected to the internet.

NSURLErrorUserCancelledAuthentication (-1012)

The connection failed because the user canceled required authentication.

NSURLErrorSecureConnectionFailed (-1200)

The secure connection failed for an unknown reason.

See Also


struct SKError

StoreKit error descriptions, codes, and domain.

enum SKError.Code

Error codes for StoreKit errors.

let SKErrorDomain: String

The error domain name for StoreKit errors.