Port 22 Connection Refused to the server

When I am creating an ec2 instance using ansible and trying to make an ssh connection in between those two servers, I am getting an issue like this:

TASK [SSH connection between the ansible server and the new server] *************************************************************
fatal: [localhost]: FAILED! => {“changed”: true, “cmd”: “cat ~/.ssh/id_rsa.pub | ssh -vvv -p 22 -i ~/.ssh/my.key ubuntu@xx.xx.xxx.xx "cat >> ~/.ssh/authorized_keys"”, “delta”: “0:00:03.052818”, “end”: “2021-10-04 05:57:48.631244”, “msg”: “non-zero return code”, “rc”: 255, “start”: “2021-10-04 05:57:45.578426”, “stderr”: “OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f 31 Mar 2020\r\ndebug1: Reading configuration data /root/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug2: resolve_canonicalize: hostname xx.xx.xxx.xx is address\r\ndebug2: ssh_connect_direct\r\ndebug1: Connecting to xx.xx.xxx.xx
[ xx.xx.xxx.xx ] port 22.\r\ndebug1: connect to address xx.xx.xxx.xx port 22: Connection refused\r\nssh: connect to host xx.xx.xxx.xx port 22: Connection refused”, “stderr_lines”: [“OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f 31 Mar 2020”, “debug1: Reading configuration data /root/.ssh/config”, “debug1: Reading configuration data /etc/ssh/ssh_config”, “debug2: resolve_canonicalize: hostname xx.xx.xxx.xx is address”, “debug2: ssh_connect_direct”, “debug1: Connecting to xx.xx.xxx.xx
[ xx.xx.xxx.xx ] port 22.”, “debug1: connect to address xx.xx.xxx.xx port 22: Connection refused”, “ssh: connect to host xx.xx.xxx.xx port 22: Connection refused”], “stdout”: “”, “stdout_lines”: }

Here “xx.xx.xxx.xx” means my newly created server’s public ip.

Any help would appreciate.

Thanks in Advance