Home > front end >  How to fix a URL colon error that changes colon to :
How to fix a URL colon error that changes colon to :

Time:07-02

I have a URL as below

components.host = "37.143.66.25:9875"

This URL contains a colon :, but when I try to make a request I get this error message

NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=http://37.143.66.25:9875/spots/test, NSErrorFailingURLKey=http://37.143.66.25:9875/spots/test, _kCFStreamErrorDomainKey=12}

And in this error message, colon : is displayed as :.

What can I do?

CodePudding user response:

Add host and port separately, like (assuming components is URLComponents)

components.host = "37.143.66.25"
components.port = 9875

otherwise it thinks that your port is part of host name

  • Related