replicate / cog

Containers for machine learning
https://cog.run
Apache License 2.0
8.05k stars 561 forks source link

Port 5000 used by AirPlay Receiver on macOS Monterey #1099

Open remorses opened 1 year ago

remorses commented 1 year ago

Mac ControlCenter is using port 5000 and 7000 https://developer.apple.com/forums/thread/682332

mattt commented 1 year ago

Hi @remorses. Thanks for pointing this out. This is the first I'd heard of Apple using those port numbers for system services.

For context, the AirPlay Receiver feature in macOS Monterey uses ports 5000 and 7000 when enabled. To disable this feature, you can open System Preferences, go to "Sharing", and uncheck "AirPlay Receiver".

The port exposed by the Docker container can be mapped to a different port on your machine. For example:

$ docker run -d --rm -p 5001:5000 hello-world

(As I mentioned in https://github.com/replicate/cog/issues/1098#issuecomment-1598485762, running Cog without Docker isn't officially supported)

I don't like the precedent of accommodating questionable design choices by Apple, but I think it's worth considering Cog using a different port by default. At the very least, we should update the example usage in our docs to map to a different port.

remorses commented 1 year ago

Currently there is no logs if the port is already used, printing a message like port 5000 already in use would already be a great improvement

mattt commented 1 year ago

@remorses There shouldn't be a port conflict when running with Docker. Just to confirm, are you proposing that we add a check to cog.server.http? My expectation is that uvicorn would raise an error if, for example, ControlCenter was already running on port 5000.

remorses commented 1 year ago

uvicorn did not throw any error but you are right that if you use Docker it will probably be Docker to throw this error

mattt commented 1 year ago

@remorses Thanks for confirming that. I just opened https://github.com/replicate/cog/pull/1103 which makes this change.