<!--
{
  "availability" : [
    "iOS: 3.0.0 - 7.0.0",
    "iPadOS: 3.0.0 - 7.0.0",
    "macOS: 10.8.0 - 10.10.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKSessionDelegate/session(_:connectionWithPeerFailed:withError:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(pl)GKSessionDelegate(im)session:connectionWithPeerFailed:withError:"
  },
  "title" : "session(_:connectionWithPeerFailed:withError:)"
}
-->

# session(_:connectionWithPeerFailed:withError:)

Received by the delegate when an attempt to connect to another peer failed.

```
optional func session(_ session: GKSession, connectionWithPeerFailed peerID: String, withError error: any Error)
```

## Parameters

`session`

The session that received the message.

`peerID`

A string that uniquely identifies the peer.

`error`

The error that occurred.

## Discussion

The `error` parameter can be used to inform the user of why the connection failed.

> Important:
> If a ``doc://com.apple.gamekit/documentation/GameKit/GKPeerPickerController`` object is being used to configure the session, the controller handles this message automatically. Your delegate can ignore it if the peer picker dialog is in use.

---

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)