<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLError",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation8URLErrorV"
  },
  "title" : "URLError"
}
-->

# URLError

Error codes returned by URL loading APIs.

```
struct URLError
```

## Overview

These error codes are for [`NSError`](/documentation/Foundation/NSError) objects in the domain [`NSURLErrorDomain`](/documentation/Foundation/NSURLErrorDomain).

## Topics

### Error details

  <doc:urlerror/2883150-errorcode>

  <doc:urlerror/2882929-erroruserinfo>

[`failingURL`](/documentation/Foundation/URLError/failingURL)

The URL which caused a load to fail.

[`failureURLPeerTrust`](/documentation/Foundation/URLError/failureURLPeerTrust)

The state of a failed SSL handshake.

[`failureURLString`](/documentation/Foundation/URLError/failureURLString)

The string for the URL which caused a load to fail.

[`downloadTaskResumeData`](/documentation/Foundation/URLError/downloadTaskResumeData)

An opaque data object used to resume a failed download task.

[`backgroundTaskCancelledReason`](/documentation/Foundation/URLError/backgroundTaskCancelledReason-swift.property)

The reason for canceling a background task.

[`URLError.BackgroundTaskCancelledReason`](/documentation/Foundation/URLError/BackgroundTaskCancelledReason-swift.enum)

An enumeration of reasons used to explain the cancellation of a background task.

[`networkUnavailableReason`](/documentation/Foundation/URLError/networkUnavailableReason-swift.property)

The reason the network was unavailable for a task.

[`URLError.NetworkUnavailableReason`](/documentation/Foundation/URLError/NetworkUnavailableReason-swift.enum)

An enumeration of reasons explaining why a task couldn’t satisfy networking constraints.

### Error domain

### Error codes

[`appTransportSecurityRequiresSecureConnection`](/documentation/Foundation/URLError/appTransportSecurityRequiresSecureConnection)

App Transport Security disallowed a connection because there is no secure network connection.

[`backgroundSessionInUseByAnotherProcess`](/documentation/Foundation/URLError/backgroundSessionInUseByAnotherProcess)

An app or app extension attempted to connect to a background session that is already connected to a process.

[`backgroundSessionRequiresSharedContainer`](/documentation/Foundation/URLError/backgroundSessionRequiresSharedContainer)

The shared container identifier of the URL session configuration is needed but hasn’t been set.

[`backgroundSessionWasDisconnected`](/documentation/Foundation/URLError/backgroundSessionWasDisconnected)

The app is suspended or exits while a background data task is processing.

[`badServerResponse`](/documentation/Foundation/URLError/badServerResponse)

The URL Loading System received bad data from the server.

[`badURL`](/documentation/Foundation/URLError/badURL)

A malformed URL prevented a URL request from being initiated.

[`callIsActive`](/documentation/Foundation/URLError/callIsActive)

A connection was attempted while a phone call is active on a network that doesn’t support simultaneous phone and data communication, such as EDGE or GPRS.

[`cancelled`](/documentation/Foundation/URLError/cancelled)

An asynchronous load has been canceled.

[`cannotCloseFile`](/documentation/Foundation/URLError/cannotCloseFile)

A download task couldn’t close the downloaded file on disk.

[`cannotConnectToHost`](/documentation/Foundation/URLError/cannotConnectToHost)

An attempt to connect to a host failed.

[`cannotCreateFile`](/documentation/Foundation/URLError/cannotCreateFile)

A download task couldn’t create the downloaded file on disk because of an I/O failure.

[`cannotDecodeContentData`](/documentation/Foundation/URLError/cannotDecodeContentData)

Content data received during a connection request had an unknown content encoding.

[`cannotDecodeRawData`](/documentation/Foundation/URLError/cannotDecodeRawData)

Content data received during a connection request couldn’t be decoded for a known content encoding.

[`cannotFindHost`](/documentation/Foundation/URLError/cannotFindHost)

The host name for a URL couldn’t be resolved.

[`cannotLoadFromNetwork`](/documentation/Foundation/URLError/cannotLoadFromNetwork)

A request to load an item only from the cache could not be satisfied.

[`cannotMoveFile`](/documentation/Foundation/URLError/cannotMoveFile)

A download task was unable to move a downloaded file on disk.

[`cannotOpenFile`](/documentation/Foundation/URLError/cannotOpenFile)

A download task was unable to open the downloaded file on disk.

[`cannotParseResponse`](/documentation/Foundation/URLError/cannotParseResponse)

A task couldn’t parse a response.

[`cannotRemoveFile`](/documentation/Foundation/URLError/cannotRemoveFile)

A download task was unable to remove a downloaded file from disk.

[`cannotWriteToFile`](/documentation/Foundation/URLError/cannotWriteToFile)

A download task was unable to write to the downloaded file on disk.

[`clientCertificateRejected`](/documentation/Foundation/URLError/clientCertificateRejected)

A server certificate was rejected.

[`clientCertificateRequired`](/documentation/Foundation/URLError/clientCertificateRequired)

A client certificate was required to authenticate an SSL connection during a request.

[`dataLengthExceedsMaximum`](/documentation/Foundation/URLError/dataLengthExceedsMaximum)

The length of the resource data exceeds the maximum allowed.

[`dataNotAllowed`](/documentation/Foundation/URLError/dataNotAllowed)

The cellular network disallowed a connection.

[`dnsLookupFailed`](/documentation/Foundation/URLError/dnsLookupFailed)

The host address couldn’t be found via DNS lookup.

[`downloadDecodingFailedMidStream`](/documentation/Foundation/URLError/downloadDecodingFailedMidStream)

A download task failed to decode an encoded file during the download.

[`downloadDecodingFailedToComplete`](/documentation/Foundation/URLError/downloadDecodingFailedToComplete)

A download task failed to decode an encoded file after downloading.

[`fileDoesNotExist`](/documentation/Foundation/URLError/fileDoesNotExist)

The specified file doesn’t exist.

[`fileIsDirectory`](/documentation/Foundation/URLError/fileIsDirectory)

A request for an FTP file resulted in the server responding that the file is not a plain file, but a directory.

[`httpTooManyRedirects`](/documentation/Foundation/URLError/httpTooManyRedirects)

A redirect loop has been detected or the threshold for number of allowable redirects has been exceeded (currently 16).

[`internationalRoamingOff`](/documentation/Foundation/URLError/internationalRoamingOff)

The attempted connection required activating a data context while roaming, but international roaming is disabled.

[`networkConnectionLost`](/documentation/Foundation/URLError/networkConnectionLost)

A client or server connection was severed in the middle of an in-progress load.

[`noPermissionsToReadFile`](/documentation/Foundation/URLError/noPermissionsToReadFile)

A resource couldn’t be read because of insufficient permissions.

[`notConnectedToInternet`](/documentation/Foundation/URLError/notConnectedToInternet)

A network resource was requested, but an internet connection hasn’t been established and can’t be established automatically.

[`redirectToNonExistentLocation`](/documentation/Foundation/URLError/redirectToNonExistentLocation)

A redirect was specified by way of server response code, but the server didn’t accompany this code with a redirect URL.

[`requestBodyStreamExhausted`](/documentation/Foundation/URLError/requestBodyStreamExhausted)

A body stream is needed but the client didn’t provide one.

[`resourceUnavailable`](/documentation/Foundation/URLError/resourceUnavailable)

A requested resource couldn’t be retrieved.

[`serverCertificateHasBadDate`](/documentation/Foundation/URLError/serverCertificateHasBadDate)

A server certificate is expired, or is not yet valid.

[`serverCertificateHasUnknownRoot`](/documentation/Foundation/URLError/serverCertificateHasUnknownRoot)

A server certificate wasn’t signed by any root server.

[`serverCertificateNotYetValid`](/documentation/Foundation/URLError/serverCertificateNotYetValid)

A server certificate isn’t valid yet.

[`serverCertificateUntrusted`](/documentation/Foundation/URLError/serverCertificateUntrusted)

A server certificate was signed by a root server that isn’t trusted.

[`secureConnectionFailed`](/documentation/Foundation/URLError/secureConnectionFailed)

An attempt to establish a secure connection failed for reasons that can’t be expressed more specifically.

[`timedOut`](/documentation/Foundation/URLError/timedOut)

An asynchronous operation timed out.

[`unknown`](/documentation/Foundation/URLError/unknown)

The URL Loading System encountered an error that it can’t interpret.

[`unsupportedURL`](/documentation/Foundation/URLError/unsupportedURL)

A properly formed URL couldn’t be handled by the framework.

[`userAuthenticationRequired`](/documentation/Foundation/URLError/userAuthenticationRequired)

Authentication is required to access a resource.

[`userCancelledAuthentication`](/documentation/Foundation/URLError/userCancelledAuthentication)

An asynchronous request for authentication has been canceled by the user.

[`zeroByteResource`](/documentation/Foundation/URLError/zeroByteResource)

A server reported that a URL has a non-zero content length, but terminated the network connection gracefully without sending any data.

[`URLError.Code`](/documentation/Foundation/URLError/Code)

Codes that describe errors within the URL loading API.



---

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)