You're getting this connection refused error is because the emulator is not running. Once you run the emulator successfully, you should not see this connection refused error. Check this old thread : https://stackoverflow.com/questions/63010406/azure-cosmos-db-on-err-connection-refused-after-installation
Issue with starting Cosmos DB Emulator
I'm facing an issue while trying to start the Cosmos DB emulator. Even after installing it and attempting to open the data explorer, I see a "localhost refused to connect" error. Can someone guide me on how to resolve this issue?