'ECONNREFUSED Error when trying to run Firebase pubsub scheduled cloud function on shell

I am trying to run a pubsub.schedule function on Firebase emulator. I tried to follow the instructions in the following links.

https://github.com/firebase/firebase-tools/issues/1748#issuecomment-609735979

https://firebase.google.com/docs/functions/local-shell#set_up_admin_credentials_optional

I keep getting the error below when I run firebase functions:shell.

Error: Server Error. connect ECONNREFUSED 127.0.0.1:4400

Any idea how to solve it? Thank you.



Solution 1:[1]

In my case, this was caused by Microsoft Defender, it may be any other firewall block. Try running "firebase emulators:start" in the same cmd window, if you get a message from MS Defender, click "Allow". Then you can stop the emulators and run "firebase functions:shell" in the same cmd window, it should work properly.

Solution 2:[2]

In my case, after running "firebase emulators:start" everything worked. It appeared that the command installed a few .jar files and perhaps that was the reason.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin R?žek
Solution 2 TheeBen