TLDR; Try a Different Browser
If you click on a Unifi devices IP address in the Cloud Key or Unifi Controller or click on “Open terminal” under tools in the device pane it should open a browser based cli
I just tried to connect using Firefox 97.0.1 and got “Connection error”
But using both Microsoft Edge and Google Chrome it works.
I have also had this happen when there was outbound rules blocking other ports but it is a good idea to try and swap browsers to double check that this is not the issue.