Mongodb connection failure after moving to another machine

I have mongodb installed on ec2 instance, I am upgrading the system so I created an image of the instance and then launched a new instance from it. Everything seems to be working properly however I am not able to connect with mongodb, it returns connection refused error. mongodb version is 3.6.5. I have restarted the mongodb, allowed location in mongo.conf, deleted lock file already but nothing works. Can someone help me with this. I am not sure what details I should provide here.

This is the response I am getting on mongo command

mongo --host (IP) --port 27017 -u ‘DBUSER’ -p ‘DBPASS’ --authenticationDatabase ‘admin’

MongoDB shell version v3.6.5
connecting to: mongodb://(IP):27017/
2021-12-21T11:45:03.486+0000 W NETWORK [thread1] Failed to connect to (IP):27017, in(checking socket for error after poll), reason: Connection refused
2021-12-21T11:45:03.498+0000 E QUERY [thread1] Error: couldn’t connect to server (IP):27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed