retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.01k stars 201 forks source link

Port 5000 may not be a safe default #688

Open kinglozzer opened 3 months ago

kinglozzer commented 3 months ago

Hi,

Every now and then when I’m working using the local development server via retype start, I get a HTTP 403 error. This really confused me for a while, until I spotted the following HTTP header in Chrome inspector: Server: AirTunes/750.14.1.

Apparently macOS now uses this port for AirPlay, so it’s sometimes available and sometimes not. What’s slightly odd is that if I stop and restart retype, it doesn’t detect that the port is already in use by something else.

lsof -i :5000
COMMAND     PID       USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ControlCe 71112 kinglozzer    8u  IPv4 0x2bfa09bfcfaa7eef      0t0  TCP *:commplex-main (LISTEN)
ControlCe 71112 kinglozzer    9u  IPv6 0x2bfa09b638bd21ef      0t0  TCP *:commplex-main (LISTEN)
ControlCe 71112 kinglozzer   23u  IPv6 0x2bfa09b6392fe9ef      0t0  TCP localhost:commplex-main->localhost:55031 (ESTABLISHED)
ControlCe 71112 kinglozzer   24u  IPv6 0x2bfa09b638c2c1ef      0t0  TCP localhost:commplex-main->localhost:55032 (ESTABLISHED)

I would suggest that fixing the port detection would be enough to solve this (so that stopping and restarting uses a different port number), but it might be better to change the default port - at least on macOS - because it may work initially, and then AirPlay will step in and steal the port at random.