<!--
{
  "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/Code",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation8URLErrorV4CodeV"
  },
  "title" : "URLError.Code"
}
-->

# URLError.Code

Codes that describe errors within the URL loading API.

```
struct Code
```

## Topics

### Error codes

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

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

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

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

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

The shared container identifier of the URL session configuration is needed but has not been set.

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

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

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

The URL Loading system received bad data from the server.

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

A malformed URL prevented a URL request from being initiated.

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

A connection was attempted while a phone call is active on a network that does not support simultaneous phone and data communication (EDGE or GPRS).

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

An asynchronous load has been canceled.

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

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

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

An attempt to connect to a host failed.

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

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

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

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

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

Content data received during a connection request could not be decoded for a known content encoding.

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

The host name for a URL could not be resolved.

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

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

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

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

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

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

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

A task could not parse a response.

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

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

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

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

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

A server certificate was rejected.

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

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

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

The length of the resource data exceeds the maximum allowed.

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

The cellular network disallowed a connection.

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

The host address could not be found via DNS lookup.

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

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

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

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

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

A file does not exist.

[`fileIsDirectory`](/documentation/Foundation/URLError/Code/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/Code/httpTooManyRedirects)

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

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

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

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

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

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

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

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

A network resource was requested, but an internet connection has not been established and cannot be established automatically.

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

A redirect was specified by way of server response code, but the server did not accompany this code with a redirect URL.

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

A body stream is needed but the client did not provide one.

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

A requested resource couldn’t be retrieved.

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

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

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

A server certificate had a date which indicates it has expired, or is not yet valid.

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

A server certificate was not signed by any root server.

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

A server certificate is not yet valid.

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

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

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

An asynchronous operation timed out.

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

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

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

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

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

Authentication is required to access a resource.

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

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

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

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



---

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)