<!--
{
  "documentType" : "article",
  "framework" : "StoreKit",
  "identifier" : "/documentation/StoreKit/handling-errors",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Handling errors"
}
-->

# Handling errors

Determine the underlying cause of errors that result from StoreKit requests.

## Discussion

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:)`](/documentation/StoreKit/SKRequestDelegate/request(_:didFailWithError:)) delegate method, it’s important to use the <doc://com.apple.documentation/documentation/Foundation/NSError/domain> and <doc://com.apple.documentation/documentation/Foundation/NSError/code> of the resulting error to determine the underlying cause of failure.

StoreKit uses [`SKErrorDomain`](/documentation/StoreKit/SKErrorDomain) for errors related to payments, store products, and cloud services, as described in [`SKError.Code`](/documentation/StoreKit/SKError/Code). For additional information on troubleshooting StoreKit framework issues, see the [In-App Purchase FAQ](https://developer.apple.com/library/archive/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228).

Errors related to networking use <doc://com.apple.documentation/documentation/Foundation/NSURLErrorDomain>. The following table describes some of the most common networking errors that may occur when using StoreKit:

|Error code                                                                                                        |Description                                                              |
|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|
|<doc://com.apple.documentation/documentation/Foundation/NSURLErrorTimedOut-swift.var> (`-1001`)                   |The connection timed out.                                                |
|<doc://com.apple.documentation/documentation/Foundation/NSURLErrorCannotFindHost-swift.var> (`-1003`)             |The connection failed because it can’t find the host.                    |
|<doc://com.apple.documentation/documentation/Foundation/NSURLErrorCannotConnectToHost-swift.var> (`-1004`)        |The connection failed because it can’t connect to the host.              |
|<doc://com.apple.documentation/documentation/Foundation/NSURLErrorNetworkConnectionLost-swift.var> (`-1005`)      |The connection failed because it lost the network connection.            |
|<doc://com.apple.documentation/documentation/Foundation/NSURLErrorNotConnectedToInternet-swift.var> (`-1009`)     |The connection failed because the device isn’t connected to the internet.|
|<doc://com.apple.documentation/documentation/Foundation/NSURLErrorUserCancelledAuthentication-swift.var> (`-1012`)|The connection failed because the user canceled required authentication. |
|<doc://com.apple.documentation/documentation/Foundation/NSURLErrorSecureConnectionFailed-swift.var> (`-1200`)     |The secure connection failed for an unknown reason.                      |

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)