Y-websocket server: listen EADDRNOTAVAIL

I am trying to run a yjs websocket server.
If I use localhost as the HOST it runs but I can’t connect to it.
If I use the repl url it can’t bind any port


HOST=y-websocket-server.tiagofreitas6.repl.co PORT=80 npx y-websocket
      throw er; // Unhandled 'error' event

Error: listen EADDRNOTAVAIL: address not available
    at Server.setupListenHandle [as _listen2] (node:net:1446:21)
    at listenInCluster (node:net:1511:12)
    at GetAddrInfoReqWrap.doListen [as callback] (node:net:1660:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:8)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1490:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -99,
  syscall: 'listen',
  address: '',
  port: 80
exit status 1

Hey there! I can’t see any of your code on the repl. You should code in the Node.js template repl, not a Blank repl. Transfer your code there.

1 Like

set up ports in .replit and change the port number to one of the supported externalPorts


I did add the ports and still doesn’t work.
Works only if I put localhost in the HOST

There is no code because I’m using npx

the code is here:

I did find a similar issue on google and they said it’s because needs to be bound to localhost on /etc/hosts but can’t do that in replit. I checked /etc/hosts and isn’t there.

just change the HOST to


localhost works on the host, but then I can’t connect to the server as I guess it doesn’t listen to the external url

so make it HOST=


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.