luckyframework / lucky_cli

A Crystal command-line tool for generating new Lucky Web Applications.
MIT License
87 stars 48 forks source link

Lucky dev/watch can not bind to port on Linux #705

Open mraffonso opened 2 years ago

mraffonso commented 2 years ago

After updating from v0.28 to v0.29 lucky watch and lucky dev can not bind to port 5000 even though the port is not in use.

I used lsof to verify that the port is not in use.

sudo lsof -i:5000

The error:

Unhandled exception: Could not bind to '127.0.0.1:5000': Address already in use (Socket::BindError)
  from /home/mario/.anyenv/envs/crenv/versions/1.2.1/share/crystal/src/socket/addrinfo.cr:74:17 in 'initialize:reuse_port'
  from /home/mario/.anyenv/envs/crenv/versions/1.2.1/share/crystal/src/socket/tcp_server.cr:32:3 in 'new:reuse_port'
  from /home/mario/.anyenv/envs/crenv/versions/1.2.1/share/crystal/src/http/server.cr:211:5 in 'bind_tcp'
  from /home/mario/.anyenv/envs/crenv/versions/1.2.1/share/crystal/src/http/server.cr:441:5 in 'listen'
  from src/app_server.cr:29:5 in 'listen'
  from src/start_server.cr:16:1 in '__crystal_main'
  from /home/mario/.anyenv/envs/crenv/versions/1.2.1/share/crystal/src/crystal/main.cr:110:5 in 'main_user_code'
  from /home/mario/.anyenv/envs/crenv/versions/1.2.1/share/crystal/src/crystal/main.cr:96:7 in 'main'
  from /home/mario/.anyenv/envs/crenv/versions/1.2.1/share/crystal/src/crystal/main.cr:119:3 in 'main'
  from __libc_start_main
  from _start
  from ???
mraffonso commented 2 years ago

The current work around is to change the following line in src/app_server.cr.

server.listen(host, port, reuse_port: false)

to:

server.listen
skojin commented 2 years ago

I just updated to 0.29 and not have this issue on my vagrant with ubuntu-20.04

I use forego for Procfile Crystal 1.0.0