Reason: If you restart the instance and trying to connect the IP will be changed in aws so, in the execution, you need to modify the IP.
Wait until the command complete execution. If that is not working or taking a long time then kindly check the IP address of your Jenkins master and the IP address in the command that you are using. If the IP is not the same update the new Master IP in the command and try to execute that will work for you.
For more information, check out this Jenkins Tutorial.