<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NEVPNConnection",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NEVPNConnection"
  },
  "title" : "NEVPNConnection"
}
-->

# NEVPNConnection

An object to start and stop a Personal VPN connection and get its status.

```
class NEVPNConnection
```

## Overview

[`NEVPNConnection`](/documentation/NetworkExtension/NEVPNConnection) objects are not instantiated directly. Instead, each `NEVPNManager` object has an associated [`NEVPNConnection`](/documentation/NetworkExtension/NEVPNConnection) object as a read-only property.

The [`NEVPNConnection`](/documentation/NetworkExtension/NEVPNConnection) class provides methods for starting and stopping the VPN programmatically. The other way that the VPN can be started and stopped is through VPN On Demand. See the `onDemandRules` property in [`NEVPNManager`](/documentation/NetworkExtension/NEVPNManager) and [`NEOnDemandRule`](/documentation/NetworkExtension/NEOnDemandRule).

Instances of this class are thread safe.

## Topics

### Controlling the VPN connection

[`-  startVPNTunnelAndReturnError:`](/documentation/NetworkExtension/NEVPNConnection/startVPNTunnel())

Start the process of connecting the VPN.

[`-  startVPNTunnelWithOptions:andReturnError:`](/documentation/NetworkExtension/NEVPNConnection/startVPNTunnel(options:))

Start the process of connecting the VPN.

[`NEVPNConnectionStartOptionUsername`](/documentation/NetworkExtension/NEVPNConnectionStartOptionUsername)

[`NEVPNConnectionStartOptionPassword`](/documentation/NetworkExtension/NEVPNConnectionStartOptionPassword)

[`-  stopVPNTunnel`](/documentation/NetworkExtension/NEVPNConnection/stopVPNTunnel())

Start the process of disconnecting the VPN.

### Getting VPN connection status

[`manager`](/documentation/NetworkExtension/NEVPNConnection/manager)

[`status`](/documentation/NetworkExtension/NEVPNConnection/status)

The current status of the VPN connection.

[`NEVPNStatus`](/documentation/NetworkExtension/NEVPNStatus)

The possible states of a VPN connection.

[`connectedDate`](/documentation/NetworkExtension/NEVPNConnection/connectedDate)

The date and time when the connection status changed to `NEVPNStatusConnected`.

### Notifications

  <doc://com.apple.documentation/documentation/Foundation/NSNotification/Name-swift.struct/NEVPNStatusDidChange>

[`NEVPNStatusDidChangeNotification`](/documentation/NetworkExtension/NEVPNStatusDidChangeNotification)

Posted when the status of the VPN connection changes.

### Notifications

[`NEVPNStatusDidChangeNotification`](/documentation/NetworkExtension/NEVPNStatusDidChangeNotification)

Posted when the status of the VPN connection changes.

### Handling errors

[`-  fetchLastDisconnectErrorWithCompletionHandler:`](/documentation/NetworkExtension/NEVPNConnection/fetchLastDisconnectError(completionHandler:))

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

[`NEVPNConnectionErrorDomain`](/documentation/NetworkExtension/NEVPNConnectionErrorDomain)

The domain for errors resulting from VPN connection calls.

[`NEVPNConnectionError`](/documentation/NetworkExtension/NEVPNConnectionError)

Error codes specific to VPN connections.

## Relationships

### Inherited By

[`NETunnelProviderSession`](/documentation/NetworkExtension/NETunnelProviderSession)

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)