Websockets: not connecting in local machine while developing

Summary

Websockets are not connecting in the local machine(localhost:< port >) while developing. The same code once deployed to the server, it’s showing all the events-related messages.

In localhost:
Screenshot 2022-04-27 at 10 45 56 PM

On server:
Screenshot 2022-04-27 at 10 46 09 PM

Steps to reproduce

Try to connect to web sockets from the local machine (localhost:< port >)

Expected behavior

Websocket connection should work even from the local machine

Observed behavior (that appears unintentional)

Events are not showing/generating in the local machine