Can you let me know why the below case 1: doesn't work; case 1: var socket = new io.Socket('localhost', {port: 4000}); socket.connect(); but the case 2, works fine. Case 2: var socket = io.connect("http://localhost:4000/");