iOS & OSX Network Error Codes

Looks like Apple have removed a number of their development articles that outline the error codes, below is quite useful for troubleshooting iOS and macOS connectivity issues.


kCFHostErrorHostNotFound      = 1,
kCFHostErrorUnknown           = 2,

SOCKS Errors

kCFSOCKSErrorUnknownClientVersion = 100,
kCFSOCKSErrorUnsupportedServerVersion = 101,
SOCKS4-Specific Errors
kCFSOCKS4ErrorRequestFailed   = 110,
kCFSOCKS4ErrorIdentdFailed    = 111,
kCFSOCKS4ErrorIdConflict      = 112,
kCFSOCKS4ErrorUnknownStatusCode = 113,

SOCKS5-specific errors

kCFSOCKS5ErrorBadState = 120,
kCFSOCKS5ErrorBadResponseAddr = 121,
kCFSOCKS5ErrorBadCredentials = 122,
kCFSOCKS5ErrorUnsupportedNegotiationMethod = 123,
kCFSOCKS5ErrorNoAcceptableMethod = 124,

FTP Errors

kCFFTPErrorUnexpectedStatusCode = 200,

HTTP Errors

kCFErrorHTTPAuthenticationTypeUnsupported = 300,
kCFErrorHTTPBadCredentials = 301,
kCFErrorHTTPConnectionLost = 302,
kCFErrorHTTPParseFailure = 303,
kCFErrorHTTPRedirectionLoopDetected = 304,
kCFErrorHTTPBadURL = 305,
kCFErrorHTTPProxyConnectionFailure = 306,
kCFErrorHTTPBadProxyCredentials = 307,
kCFErrorPACFileError = 308,
kCFErrorPACFileAuth = 309,
kCFErrorHTTPSProxyConnectionFailure = 310,
kCFStreamErrorHTTPSProxyFailureUnexpectedResponseToCONNECTMethod = 311,

CFURL and CRUFLConnection Errors

These error codes also match NSURLErrorDomain error codes

kCFURLErrorUnknown   = -998,
kCFURLErrorCancelled = -999,
kCFURLErrorBadURL    = -1000,
kCFURLErrorTimedOut  = -1001,
kCFURLErrorUnsupportedURL = -1002,
kCFURLErrorCannotFindHost = -1003,
kCFURLErrorCannotConnectToHost    = -1004,
kCFURLErrorNetworkConnectionLost  = -1005,
kCFURLErrorDNSLookupFailed        = -1006,
kCFURLErrorHTTPTooManyRedirects   = -1007,
kCFURLErrorResourceUnavailable    = -1008,
kCFURLErrorNotConnectedToInternet = -1009,
kCFURLErrorRedirectToNonExistentLocation = -1010,
kCFURLErrorBadServerResponse             = -1011,
kCFURLErrorUserCancelledAuthentication   = -1012,
kCFURLErrorUserAuthenticationRequired    = -1013,
kCFURLErrorZeroByteResource        = -1014,
kCFURLErrorCannotDecodeRawData     = -1015,
kCFURLErrorCannotDecodeContentData = -1016,
kCFURLErrorCannotParseResponse     = -1017,
kCFURLErrorInternationalRoamingOff = -1018,
kCFURLErrorCallIsActive               = -1019,
kCFURLErrorDataNotAllowed             = -1020,
kCFURLErrorRequestBodyStreamExhausted = -1021,
kCFURLErrorFileDoesNotExist           = -1100,
kCFURLErrorFileIsDirectory            = -1101,
kCFURLErrorNoPermissionsToReadFile    = -1102,
kCFURLErrorDataLengthExceedsMaximum   = -1103,

SSL Errors

kCFURLErrorSecureConnectionFailed          = -1200,
kCFURLErrorServerCertificateHasBadDate     = -1201,
kCFURLErrorServerCertificateUntrusted      = -1202,
kCFURLErrorServerCertificateHasUnknownRoot = -1203,
kCFURLErrorServerCertificateNotYetValid    = -1204,
kCFURLErrorClientCertificateRejected       = -1205,
kCFURLErrorClientCertificateRequired       = -1206,
kCFURLErrorCannotLoadFromNetwork           = -2000,

Download and file I/O errors

kCFURLErrorCannotCreateFile = -3000,
kCFURLErrorCannotOpenFile = -3001,
kCFURLErrorCannotCloseFile = -3002,
kCFURLErrorCannotWriteToFile = -3003,
kCFURLErrorCannotRemoveFile = -3004,
kCFURLErrorCannotMoveFile = -3005,
kCFURLErrorDownloadDecodingFailedMidStream = -3006,
kCFURLErrorDownloadDecodingFailedToComplete = -3007,

Cookie Errors

kCFHTTPCookieCannotParseCookieFile = -4000,

Errors Originating from CFNetServices

kCFNetServiceErrorUnknown     = -72000L,
kCFNetServiceErrorCollision   = -72001L,
kCFNetServiceErrorNotFound    = -72002L,
kCFNetServiceErrorInProgress  = -72003L,
kCFNetServiceErrorBadArgument = -72004L,
kCFNetServiceErrorCancel      = -72005L,
kCFNetServiceErrorInvalid     = -72006L,
kCFNetServiceErrorTimeout     = -72007L,
kCFNetServiceErrorDNSServiceFailure = -73000L,
Error Description OSX Version
kCFHostErrorHostNotFound Indicates that the DNS lookup failed. 10.5 and later
kCFHostErrorUnknown An unknown error occurred (a name server failure, for example). For additional information, you can query the kCFGetAddrInfoFailureKey key to obtain the value returned by getaddrinfo and look up the value in /usr/include/netdb.h. 10.5 and later
kCFSOCKSErrorUnknownClientVersion The SOCKS server rejected access because it does not support connections with the requested SOCKS version. SOCKS client version. You can query the kCFSOCKSVersionKey key to find out what version the server requested. 10.5 and later
kCFSOCKSErrorUnsupportedServerVersion The version of SOCKS requested by the server is not supported. You can query the kCFSOCKSVersionKeykey to find out what version the server requested. 10.5 and later
kCFSOCKS4ErrorRequestFailed Request rejected by the server or request failed. This error is specific to SOCKS4. 10.5 and later
kCFSOCKS4ErrorIdentdFailed Request rejected by the server because it could not connect to the identd daemon on the client. This error is specific to SOCKS4. 10.5 and later
kCFSOCKS4ErrorIdConflict Request rejected by the server because the client program and the identd daemon reported different user IDs. This error is specific to SOCKS4. 10.5 and later
kCFSOCKS4ErrorUnknownStatusCode The status code returned by the server is unknown. This error is specific to SOCKS4. 10.5 and later
kCFSOCKS5ErrorBadState The stream is not in a state that allows the requested operation. 10.5 and later
kCFSOCKS5ErrorBadResponseAddr The address type returned is not supported 10.5 and later
kCFSOCKS5ErrorBadCredentials The SOCKS server refused the client connection because of bad login credentials. 10.5 and later
kCFSOCKS5ErrorUnsupportedNegotiationMethod The requested method is not supported. You can query the kCFSOCKSNegotiationMethodKey key to find out which method the server requested. 10.5 and later
kCFSOCKS5ErrorNoAcceptableMethod The client and server could not find a mutually agreeable authentication method. 10.5 and later
kCFFTPErrorUnexpectedStatusCode The server returned an unexpected status code. 10.5 and later
kCFErrorHTTPAuthenticationTypeUnsupported The client and server could not agree on a supported authentication type. 10.5 and later
kCFErrorHTTPBadCredentials The credentials provided for an authenticated connection were rejected by the server 10.5 and later
kCFErrorHTTPConnectionLost The connection to the server was dropped. This usually indicates a highly overloaded server 10.5 and later
kCFErrorHTTPParseFailure The HTTP server response could not be parsed. 10.5 and later.
kCFErrorHTTPRedirectionLoopDetected Too many HTTP redirects occurred before reaching a page that did not redirect the client to another page. This usually indicates a redirect loop 10.5 and later.
kCFErrorHTTPBadURL The requested URL could not be retrieved. 10.5 and later.
kCFErrorHTTPProxyConnectionFailure A connection could not be established to the HTTP proxy. v10.5 and later.
kCFErrorHTTPBadProxyCredentials The authentication credentials provided for logging into the proxy were rejected. 10.5 and later.
kCFErrorPACFileError An error occurred with the proxy autoconfiguration file. 10.5 and later.
kCFErrorPACFileAuth The authentication credentials provided by the proxy autoconfiguration file were rejected. 10.6 and later.
kCFErrorHTTPSProxyConnectionFailure A connection could not be established to the HTTPS proxy. 10.6 and later.
kCFStreamErrorHTTPSProxyFailureUnexpectedResponseToCONNECTMethod The HTTPS proxy returned an unexpected status code, such as a 3xx redirect. 10.7 and later
kCFURLErrorUnknown An unknown error occurred. 10.6 and later
kCFURLErrorCancelled The connection was cancelled. 10.6 and later
kCFURLErrorBadURL The connection failed due to a malformed URL. 10.6 and later
kCFURLErrorTimedOut The connection timed out. 10.6 and later
kCFURLErrorUnsupportedURL The connection failed due to an unsupported URL scheme. 10.6 and later
kCFURLErrorCannotFindHost The connection failed because the host could not be found. 10.6 and later
kCFURLErrorCannotConnectToHost The connection failed because a connection cannot be made to the host. 10.6 and later
kCFURLErrorNetworkConnectionLost The connection failed because the network connection was lost. 10.6 and later
kCFURLErrorDNSLookupFailed The connection failed because the DNS lookup failed. 10.6 and later
kCFURLErrorHTTPTooManyRedirects The HTTP connection failed due to too many redirects. 10.6 and later
kCFURLErrorResourceUnavailable The connection’s resource is unavailable. 10.6 and later
kCFURLErrorNotConnectedToInternet The connection failed because the device is not connected to the internet. 10.6 and later
kCFURLErrorRedirectToNonExistentLocation The connection was redirected to a nonexistent location. 10.6 and later
kCFURLErrorBadServerResponse The connection received an invalid server response. 10.6 and later.
kCFURLErrorUserCancelledAuthentication The connection failed because the user cancelled required authentication. 10.6 and later.
kCFURLErrorUserAuthenticationRequired The connection failed because authentication is required. 10.6 and later
kCFURLErrorZeroByteResource The resource retrieved by the connection is zero bytes. 10.6 and later
kCFURLErrorCannotDecodeRawData The connection cannot decode data encoded with a known content encoding. 10.6 and later
kCFURLErrorCannotDecodeContentData The connection cannot decode data encoded with an unknown content encoding. 10.6 and later
kCFURLErrorCannotParseResponse The connection cannot parse the server’s response. 10.6 and later
kCFURLErrorInternationalRoamingOff The connection failed because international roaming is disabled on the device. 10.6 and later.
kCFURLErrorCallIsActive The connection failed because a call is active. 10.6 and later.
kCFURLErrorDataNotAllowed The connection failed because data use is currently not allowed on the device. 10.6 and later.
kCFURLErrorRequestBodyStreamExhausted The connection failed because its request’s body stream was exhausted. 10.6 and later
kCFURLErrorFileDoesNotExist The file operation failed because the file does not exist. 10.6 and later
kCFURLErrorFileIsDirectory The file operation failed because the file is a directory. v10.6 and later
kCFURLErrorNoPermissionsToReadFile The file operation failed because it does not have permission to read the file. v10.6 and later
kCFURLErrorDataLengthExceedsMaximum The file operation failed because the file is too large. 10.6 and later
kCFURLErrorSecureConnectionFailed The secure connection failed for an unknown reason 10.6 and later
kCFURLErrorServerCertificateHasBadDate The secure connection failed because the server’s certificate has an invalid date. 10.6 and later
kCFURLErrorServerCertificateUntrusted The secure connection failed because the server’s certificate is not trusted. 10.6 and later
kCFURLErrorServerCertificateHasUnknownRoot The secure connection failed because the server’s certificate has an unknown root. 10.6 and later
kCFURLErrorServerCertificateNotYetValid The secure connection failed because the server’s certificate is not yet valid. 10.6 and later
kCFURLErrorClientCertificateRejected The secure connection failed because the client’s certificate was rejected. 10.6 and later
kCFURLErrorClientCertificateRequired The secure connection failed because the server requires a client certificate. 10.6 and later
kCFURLErrorCannotLoadFromNetwork The connection failed because it is being required to return a cached resource, but one is not available. 10.6 and later
kCFURLErrorCannotCreateFile The file cannot be created. 10.6 and later
kCFURLErrorCannotOpenFile The file cannot be opened 10.6 and later
kCFURLErrorCannotCloseFile The file cannot be closed 10.6 and later
kCFURLErrorCannotWriteToFile The file cannot be written. 10.6 and later
kCFURLErrorCannotRemoveFile The file cannot be removed. 10.6 and later
kCFURLErrorCannotMoveFile The file cannot be moved. 10.6 and later
kCFURLErrorDownloadDecodingFailedMidStream The download failed because decoding of the downloaded data failed mid-stream. 10.6 and later
kCFURLErrorDownloadDecodingFailedToComplete The download failed because decoding of the downloaded data failed to complete. 10.6 and later
kCFHTTPCookieCannotParseCookieFile The cookie file cannot be parsed. 10.6 and later
kCFNetServiceErrorUnknown An unknown error occurred. 10.2 and later
kCFNetServiceErrorCollision An attempt was made to use a name that is already in use. 10.2 and later.
kCFNetServiceErrorNotFound Not used. 10.2 and later.
kCFNetServiceErrorInProgress A new search could not be started because a search is already in progress. 10.2 and later
kCFNetServiceErrorBadArgument A required argument was not provided or was not valid. 10.2 and later.
kCFNetServiceErrorCancel The search or service was cancelled. 10.2 and later
kCFNetServiceErrorInvalid Invalid data was passed to a CFNetServices function. 10.2 and later
kCFNetServiceErrorTimeout A search failed because it timed out. 10.2 and later
kCFNetServiceErrorDNSServiceFailure DNS service discovery returned an error. You can query the kCFDNSServiceFailureKey key to find out the error returned by DNS service discovery and look up the code in /usr/include/dns_sd.h or DNS Service Discovery C Reference. 10.5 and later
1 Like