pythonpyez

PyEZ: jnpr.junos.exception.ConnectRefusedError: ConnectRefusedError(xx.xxx.xxx.xxx)


PyEZ Device connection returns ConnectRefusedError.

>>> dev = Device(host='xx.xxx.xx.xx', user='xxxx',password='xxxx')
>>> dev.open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\jnpr\junos\device.py", line 459, in open
    raise EzErrors.ConnectRefusedError(self)
jnpr.junos.exception.ConnectRefusedError: ConnectRefusedError(xx.xxx.xx.xx)

Solution

  • It looks like netconf is not enabled on the given device. (hence PyEZ is not able to connect to netconf default 830 port).

    We have 2 option

    Enable netconf on device using below config command

    "set system services netconf ssh"
    

    Or pass port=22 in device class, so that PyEZ uses sh port to communicate in place of netconf 830 port.

    dev = Device(host='xx.xx.xx.xxx', user='xxx', password='xxxx', port=22)