---
title: "connection(_:didFailWithError:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurlconnectiondelegate/connection(_:didfailwitherror:)"
---

# connection(_:didFailWithError:)

Sent when a connection fails to load its request successfully.

## Declaration

```swift
optional func connection(_ connection: NSURLConnection, didFailWithError error: any Error)
```

## Parameters

- `connection`: The connection sending the message.
- `error`: An error object containing details of why the connection failed to load the request successfully.

## Discussion

Discussion Once the delegate receives this message, it will receive no further messages for connection.
