0

I am trying to query WHOIS server through code but I am getting exception :

No connection could be made because the target machine actively refused it

If I look at the details of SocketException then I see ErrorCode = 10061, which is for:

No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.

My Code is:

using (TcpClient tcpClinetWhois = new TcpClient("whois.internic.net", 43))

I have also tried "whois.cira.ca", but both of them are returning the same error.

I have searched for the error, disabled my firewall, also tried opening port 43 for TCP connections on my computer but nothing seemed to have resolved it. Any idea why this would happen ?

I am actually trying to get Primary and Secondary domain names for a url.

CriketerOnSO
  • 2,600
  • 2
  • 15
  • 24
  • If by "Primary and Secondary domain names for a url" you mean "nameservers list of a domain name" then whois is the wrong tool for the job. You should instead do DNS queries for the domain name in the URL, and get back resources records for type NS. – Patrick Mevzek Jan 02 '18 at 20:03
  • I assume this does not help many others. I think the thread that does is [How to get whois information of a domain name in my program?](https://stackoverflow.com/questions/53623/how-to-get-whois-information-of-a-domain-name-in-my-program). – Sam Hobbs Sep 21 '19 at 05:44

1 Answers1

0

The error was disabled 43 port on Network firewall. Opening port 43 on my local computer didn't had any effect. I had to approach Network staff and once they open the port 43, it was all fine.

CriketerOnSO
  • 2,600
  • 2
  • 15
  • 24