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

https://replit.com/@TiagoFreitas6/y-websocket-server

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

Error: listen EADDRNOTAVAIL: address not available 34.110.138.177:80
    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) {
  code: 'EADDRNOTAVAIL',
  errno: -99,
  syscall: 'listen',
  address: '34.110.138.177',
  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

2 Likes

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 0.0.0.0 needs to be bound to localhost on /etc/hosts but can’t do that in replit. I checked /etc/hosts and 0.0.0.0 isn’t there.

just change the HOST to 0.0.0.0

2 Likes

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=0.0.0.0

3 Likes

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