In Windows use the following steps:
Open PowerShell as Administrator.
stop winnat with the command:
net stop winnat
start winnat again with the command:
net start winnat
const server = require('http').createServer();
const port = process.env.PORT || 3000;
server.listen(port, () => console.log(`Listening on ${port}`));
If anyone else is having a similar problem on windows. The issue is the virtual ethernet adapter created by docker. Once I disabled it everything went back to working normally.
change to another port like 5000 | 8000