fava icon indicating copy to clipboard operation
fava copied to clipboard

Change default port (at least on macOS)

Open caesar opened this issue 3 years ago • 4 comments

macOS now uses port 5000 by default for AirPlay discovery (https://news.ycombinator.com/item?id=29006861). Attempting to start Fava with the default port now fails silently on macOS (it says it's running, but the web interface doesn't load because the port is already in use by the system).

Port 5000 is in any case already a reserved port for UPnP:

  • https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?&page=88
  • https://www.grc.com/port_5000.htm

It would be better to use a port in the 8000+ range (and also to detect if the port is already in use and fall back to a higher port).

caesar avatar Jan 23 '22 12:01 caesar

Thanks for the report :)

This port was chosen simply by being the default port that the Flask dev server binds on. I think I'll stick with that default like Flask (https://github.com/pallets/flask/issues/4328), but Fava should definitely error out if the port is already in use. It seems that it currently doesn't due to cheroot binding to ip6 localhost (so [::1]:5000) if ip4 localhost is in use (which I find to be surprising behaviour). I'll fix that.

yagebu avatar Jan 29 '22 12:01 yagebu

Encountered this issue today. Seems like the error handling in #1378 may not be working.

chrisirhc avatar Jan 02 '25 22:01 chrisirhc

A PR with a fix would be welcome then :)

yagebu avatar Jan 03 '25 15:01 yagebu

You can just add an alias in the ~/.zshrc file to set the port to a different one. I don't have issues with it on MacOS.

alias startfava="fava main.beancount -p 5001"

You can then just type startfava in your Terminal. Edit the port and file to your needs

jbrok avatar Apr 04 '25 15:04 jbrok