CPM Agent may fail to connect to the CPM Server with errors 10060 or 10061

CPM Agent may fail to connect to the CPM Server with errors 10060 or 10061

CPM Agent may fail to connect to the CPM Server with errors 10060 or 10061:

failed calling url https://cpmserver/agentapi/XYZ/. Exception: <urlopen error [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>
...
failed calling url https://cpmserver/agentapi/XYZ/. Exception: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>

These errors will be logged when the Agent is trying to connect to the wrong IP/Hostname or port for the CPM Server.

Often the IP/Hostname changes because the CPM Server was stopped and started, or it was rebuilt/upgraded through using a new AMI.
Using Elastic IP will prevent this problem from happening in the future.

Solution:
1) Stop the CPM Agent Service
2) Edit the cpmagent.cfg in Agent's installation folder to reflect the new IP/hostname
3) Start the CPM Agent Service

Alternatively, the problem may be caused by your security group settings or proxy settings.

To verify that the connectivity between Agent and CPM Server is not blocked, you can open CPM's GUI in a browser on the Agent's instance.
If the browser can connect, so can the Agent.