My node server and client are running on different ports(3001,5347 respectively). On client I had used,
var socket = io(\'http://127.0.0.1:3001\'); >
var socket = io(\'http://127.0.0.1:3001\');
Following code helped:
const PORT = process.env.PORT || 4000; const app = express(); const server = app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); }); const io = socket(server);