<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NEVPNConnection/fetchLastDisconnectError(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NEVPNConnection(im)fetchLastDisconnectErrorWithCompletionHandler:"
  },
  "title" : "fetchLastDisconnectError(completionHandler:)"
}
-->

# fetchLastDisconnectError(completionHandler:)

Retrives the most recent error that caused the VPN to disconnect.

```
func fetchLastDisconnectError(completionHandler handler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`handler`

An error handler that receives the last disconnect error as a parameter.

## Discussion

If VPN system (including the IPsec client) generated the error, then the error uses the [`NEVPNConnectionErrorDomain`](/documentation/NetworkExtension/NEVPNConnectionErrorDomain) error domain. If the error came from a tunnel provider app extension instead, then the error is the <doc://com.apple.documentation/documentation/Foundation/NSError> that the provider passed when disconnecting the tunnel.

---

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)