Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found

I get this error when I try running the app on a device. I do not get this error when I run it on the simulator and the post request works fine. This is code snippet I have:

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url    cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:300.f];
[request setHTTPMethod:@"POST"];

NSData* data = [paramString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:data];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection start];

Any help is appreciated. Thanks

like image 977
shriniwas_ayyer Avatar asked Dec 02 '14 20:12

shriniwas_ayyer


People also ask

What does nsurlerrordomain code=-1003 mean?

Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found

Is there a server with the specified hostname could not be found?

Several users have complained about getting the “A server with the specified hostname could not be found” error in Mac. This error is just one of the many bugs that have been plaguing the newly released macOS Big Sur. What is the Cannot install from App Store.

Why is the host name in my url wrong?

The host name in your URL is wrong because the message you are getting back explicitly states it can't find a server with that host name. The mst likely cause is that you have forgotten to put a forward slash between the base URL and the email e.g. if your base URL is

What does error code-1003 mean?

iOS Error Code=-1003 "A server with the specified hostname could not be found." Ask Question Asked4 years, 9 months ago Active1 year, 2 months ago Viewed34k times 30 4 I am trying to load image from URL on the iphone, image is there and I can open it in safari with same link, but not in the app:


1 Answers

With Xcode 11.2.1, working on a macOS project, I had the same issue.

The fix here was:

  • Click on project in project explorer
  • Select the Signing & Capabilities tab
  • Check "Network: Outgoing connections (client)" checkbox in the AppSandbox section
like image 166
sarfata Avatar answered Sep 21 '22 09:09

sarfata