Search code examples
pythonpython-3.xtelnettelnetlib

How to connect telnet to particular port of host?


I have HOST='xx.xxx.xx.xx' and PORT = xxxx

I tried                    

tn = telnetlib.Telnet(HOST, port=PORT, timeout=5)

I'm getting this error

ConnectionRefusedError: [Errno 61] Connection refused

Is there any other way to telnet to port other than default one?


Solution

  • ConnectionRefused means that the Server refused your connection, which in-turn could mean that telnet service is not running on that port. You can do telnet to any port only as long as the telnet service in running on that port in the server.