Troubleshoot Junos PyEZ Connection Errors
Problem
Description
When using Junos PyEZ to manage Junos devices, the code generates an error that the connection was refused. For example:
jnpr.junos.exception.ConnectRefusedError
Cause
NETCONF is not enabled on the device or the number of connections exceeds the limit.
The most likely cause for a refused connection error is that NETCONF over SSH is not enabled on the Junos device. To quickly test whether NETCONF is enabled, verify that the user account can successfully start a NETCONF session with the device.
[user@server]$ ssh user@R1.example.com -p 830 -s netconf
Solution
If NETCONF is not enabled on the Junos device, enable NETCONF.
[edit] user@R1# set system services netconf ssh user@R1# commit
If the number of NETCONF sessions exceeds the limit, increase the maximum number of permitted sessions up to 250. The default is 75.
[edit] user@R1# set system services netconf ssh connection-limit limit user@R1# commit