Why is Control Center on Monterey listening on ports?
developer.apple.com
developer.apple.com
* It's the new AirPlay server capability.
* It can be toggled off.
* Those ports are the defaults for AirPlay.
It might've been nice to allow simple way of customizing the ports though..
Update: "It would appear commplex was a part of seeplex, some visualization tool for old Sun workstations in the early 90ies https://lib.dr.iastate.edu/cgi/viewcontent.cgi?article=11617..."
"The Commplex is a communications package for communication with the NCUBE from Sun workstations."
> * Those ports are the defaults for AirPlay.
No, those are the default port for UPnP discovery, and have been used also by Microsoft in the XP days. There's a reason Apple picked them: it's aligned with their use case, and already assigned by what, 16 years or so?
Probably also the context that you're missing, since that this post is actually somewhat a dupe.
My company's product contains a web server. We don't bother to check to see if some other program is using port 80 or 443, we just use it. The reason is that we own the machine, we install the software, and we know there is nothing running on these ports; and more, if something is on these ports, we have no way to recover, so terminating abnormally is the right answer.
Picking a random port when you have been told to pick a specific port (even implicitly) makes no sense. What if I start flask telling it to use 8000 and it’s already taken by an other program I’m running (something I do semi-regularly as I run tests concurrently), just pick a random port unasked and notify no one about it?
"Listening on port $PORT. Warning: failed to bind localhost:5000. Start process with --port=$X to specify a different port"
That would be much more helpful behavior and messaging than simply failing, especially since it seems people don't know that they can control the port, and start looking to disabling OS services rather than changing a port...
But why this part? Python -m http.server tells me which port it is using or gives me "OSError: [Errno 48] Address already in use".
In fact, I just tried
python -m http.server $((10000 + RANDOM % 10000))
and it told me what port it started using.
Sockets cannot collide, therefore you cannot bind more than one service running on a host to the same socket, which means if both are using INADDR_ANY, they cannot use the same port. Nothing prevents you from having multiple IPs on a host, each bound by IP to the same port (which would be separate sockets).
For CLIENT applications, they aren't just utilizing sockets, they're utilizing connections, and a connection is a tuple of two sockets. You can have many many many connections utilizing the same port, as long as they don't collide exactly with the socket on the other side in their signature. There are various ways to handle this, but a typical one is that servers do a hand-off during connection initialization to a temporary port assigned to that connection.
So, Flask (a server), is saying you can't bind it to listen on a socket which is previously bound because it would cause a collision and violate the no-collision rule for sockets. But it doesn't in any way mean that port can't be overloaded by different sockets being bound to the same port.
> There are various ways to handle this, but a typical one is that servers do a hand-off during connection initialization to a temporary port assigned to that connection.
I don't think this is right. Servers don't normally use additional ports. Instead, a process can actually create multiple TCP (streaming) sockets with the same local address:local port combination, but different remote address:remote port combinations (each TCP socket is uniquely identified by a four-tuple).
The point though was that once Flask realizes that it can't bind the address:TCP socket, it shouldn't just give up without even telling users about other options.
It's not the only way to address this issue, but it is a common pattern for servers to do a TCP handoff to an ephemeral port during connection initialization. One of the reasons that this is done is because it allows you to have /multiple/ connections from the same client to the same server, which is useful for a number of reasons. You're correct that each TCP connection (which is two sockets, a socket is IP + port) four-tuple with a different remote IP or remote port is considered a separate identifiable entity, so in some cases that means the client is responsible for providing an ephemeral port that should be connected back on. It depends on a variety of factors. If neither side does this, then you are limited to a single connection for that protocol for a single client.
If you'd like to investigate some common servers that use connection handoff and ephemeral ports look at nginx and haproxy, both do this and can also suffer from ephemeral port exhaustion on heavily loaded servers because of it (there are mitigation strategies as well).
Their usage of port 5000 appears compliant with IANA port designation.
I picked specifically 5000 because the IANA registration for this port was assigned to a single service, was not used and generally obscure. Whatever Apple has running on there is also unlikely to be what the IANA registration refers to.
Here's a quotation:
> Just did a bit more digging, and IANA actually assigns port 5000 to "commplex-main" - so really any other service that's using that port is violating the official assignment. Based on a quick search of what commplex-main is, it's related to UPnP for network device discoverability. I'm not sure exactly what the AirPlay Receiver service does, but I get the gist that it probably does fit somewhere into the scope of UPnP-related features. At the very least, it's probably a far more accurate usage of port 5000 than some random dev servers.
This port was actually also used back in XP and * Lion days both by Apple and Microsoft, but I have a hunch that *.local replaced these use cases and that's why it became disused until recently.
> The Commplex is a communications package for communication with the NCUBE from Sun workstations.
Wait, all roads lead to Oracle?
So, uhm, this reminds me of STMPS and port 465. Read about it, and it's a sad state of affairs because of a blunder in managing that list. Funnily, mail providers and Cisco share that port (and no, not a TCP/UDP split, both are for TCP connections).
So who suggested to use port 5000 then way back? That's a serious question that is now my homework for this conversation.
I'm not sure how this came to be to be honest. This is a very old system, but yet we still abuse the four digit range with private use ports. I mean, it's often just one digit away. Even as defaults in software packages where their developers should at least know better even if a random web developer might not.
Yeah, and while we're at it, let's burn all IETF RFCs. Who needs that?
1) To cite it in a smart hacker news comment 2) To show alarming text in "security scans" to gullible people
Seriously, google "commplex" and all you find is confused home users thinking they got a trojan of sorts. In 2021, it is purely a drain on everyones nerves.
Pretty sure those are not drains on everybody's nerves. Devs bashing standards cause they don't want to follow the rules which make things work well is a drain on everyone's nerves.
But maybe I have misunderstood the document (didn't read). Standards are nice, except when they are mostly geared towards one company. Then yeah, it would be better to have SRV records and discourage default port usage such as Apple is doing.
If we could go back in time, forcing an app layer (e.g. an ssh header) over a port might have been helpful, port conflicts might have been less common and you could have even eliminated root only ports.
At any rate let's not break the web because some lazy mofo doesn't want to get off their couch.
AFAIK that's mostly a GNOME issue, so despite it wrongly, IMO, being the default and the most popular DE of the Linux distros for some reason, I wouldn't throw mud on the whole Linux DE ecosystem because of it alone.
KDE, LXQT, LXDE and XFCE seem to have their shit together for the most part.
I'm no fanboy and have no dog in this DE fight, just curious.
Sadly, its almost certainly too late to add port numbers to DNS.
It is just a matter of specifying the use of such entries in the protocols (HTTP et al). A lot of new protocols already rely on them.
As someone who doesn't do much infra, I've encountered them when setting up the DNS for a Minecraft server. The game checks for the SRV record, or if it is missing, assumes (or reads from the user) a given port.
Do you know what the rationale is for not adding them to HTTP2 / HTTP3?
The only time fixed port numbers are inconvenient is when they conflict, but otherwise they're much easier to work with.
Of course, one day the technical inferiority finally shows itself (e.g., the ports do conflict), and then people start to heroically overcome the obstacles they've created for themselves, showing outstanding feats of ingenuity. Just google "port allocator"! Every company inevitably writes their own home-grown one because everyone's deployment/integration pipeline is unique.
It’s likely that the port will be available indefinitely.
This already works by just telling flask to use port 0. Binding to port 0 is standard behaviour (literally, part of the standard) and like most other software of that type the first thing Flask does is report the URL it’s running on.
> but it offers tremendous convenience.
Except when it does not as is the case here. If you’re working on your web stuff having to copy/paste a URL from your term every time you restart your server.
I've seen a couple of programs that explicitly check and refuse to start when asked to listen on port 0 (for example, to this day "ssh -D 127.0.0.1:0 remote-host" refuses to start).
> If you’re working on your web stuff having to copy/paste a URL from your term every time you restart your server.
Don't the developer's standard server-launching scripts (re)launch browser after they start the server? IIRC, npm start and VisualStudio+ASP.NET do exactly that.
(The main non-IANA compliant user of the port is Flask, a Python-based web framework.)
def doSomething(theArgs, cb):
food, bard = 0, 0
try:
doFoo(theArgs["foo"], lambda: food = 1)
doBar(theArgs["bar"], lambda: bard = 1)
except Exception:
cb(food + bard, "didn't work")
else:
cb(food + bard, None)
or whatever.I can get by in JS, I use it professionally even now, but it's not good quality; I know that. (Trivial example, I discovered `??` recently. I've definitely written a lot of null/undefined checks without it, or even naive ternaries that assume non-null/undef values aren't falsey (`thing ? thing : 123` vs. `thing ?? 123`) - which is kind of like seeing `dict.get(key, None)` in python.)
What takes a while is another engineering principle that people are sometimes bitten by, trying to understand why a change in the system has occurred - in this case why your port that you always use is suddenly no longer open despite you not having done anything that you are aware of that might have closed it. Of course you want to understand why this change has happened because it seems weird, is there something nefarious going on at port 5000 now!?! Also because of all the things said above about wanting to not change all occurrences of 5000 in your developer docs and so forth so it would be nice if you figure out, as was shown as the top voted answer of the article, that you could go to somewhere in settings and turn off this usage of the port. I mean you could just scan and change what port you use to another currently open port without worrying about any of this stuff, which I guess would have worked in this case but I can't help but feel that would not really appear the best move whenever strange unexplained port usage changes occur. Your mileage evidently varies.
[1] https://www.iana.org/assignments/service-names-port-numbers/...
[2] The actual rate is something like 3--50 new and updated entries per year.
If port collisions were such a hassle, we wouldn't see anything like a "common" port (i. e. one that unrelated tools choose per default).
Good developers can have a pipe in every port, I guess...
(valid for development work only, especially those cases where you run some server and it opens the browser for you, port helpfully provided. There is value in ssh on 22 and http on 80, obvsly)
For those wondering why I needed port 5000 in my case, it was a standard Svelte app serving on localhost:5000 (via Sirv).
Is Svelte hard-wired to 5000?
I started off thinking it was a bit ridiculous that people developing wouldn’t just think ‘oh port 5000 is busy - let me try -p 6000 when running this’ but I see that was a wrong assumption, because the tool itself seems to perhaps be flawed in that it isn’t making it easy to diagnose and change how it runs to sidestep the used port.
Perhaps a feature request for svelte is in order?
Also why is there no official TLD for DNS for local domains?
As of now, but something about IPv6 also forced Microsoft to implement this, and some Linux distros also does this in CUPS (I know it's Apple...)
I use .home and it's fine, but there's the occasional oddity when e.g. Chrome doesn't recognise "myserver.home" as a FQDN as ".home" isn't on its built in list of TLDs
So, there's at least _some_ precedent that previously reserved things become unreserved :(
Though in this list, only .test and .example are marked as non-special and must be resolved normally by RFC 6761, and .local is reserved for mDNS by RFC 6762. In this list, .test would have been the most appropriate for Pow to use.
CydeWeys (Tech Lead of Google Registry) has commented on HN in the past that they did not anticipated people weren't following the best practices[4], which makes me think IANA should have given .dev the same treatment as .onion: by explicitly reserving them (but this is another topic to discuss).
[1]: https://github.com/basecamp/pow
[2]: https://github.com/laravel/valet
https://www.searchenginejournal.com/google-opens-up-dev-doma...
That's a lot different from "never using it" and it isn't like they publicly made a pledge that was what they were going to do with it...
says: “The proposed gTLD will provide Google with direct association to the term “dev,” which is an abbreviation of the word, “development.” The mission of this gTLD, .dev, is to provide a dedicated domain space in which Google can enact second-level domains specific to its projects in development.”
and goes on to say:
> “18(b). How do you expect that your proposed gTLD will benefit registrants, Internet users, and others?
> Given its intended use by Google, the .dev gTLD will best add value to the gTLD space by remaining completely closed for the sole use of Google.”
And finally:
> “18(c). What operating rules will you adopt to eliminate or minimize social costs?
> Members of the public will not be able to register domain names in this new gTLD.”
Reading that proposal is _clear_ to me that it’s for internal use only and that the impact to the global internet is that “it does not exist”. (And even hinting that it’s a good thing).
Obviously they never _comitted_ to never using it, but it is absolutely apparent that their intent was “internal to google, unused outside” and given how poisoned the .dev namespace was already at that time: it was met with somewhat apprehensive open arms.
Google then went and opened it and made it impossible to use locally by pinning HSTS on the TLD level. Which is basically the worst thing they could have done with it, given that people were using it locally already.. and some popular frameworks even recommended it as an option when running locally.
(Though, there is an argument to be made there that they made sure things worked as expected by forcing the public use of .dev)
Obviously it’s fine now. But don’t pretend this was obvious.
It's in their gTLD application for .dev[1]
> The mission of this gTLD, .dev, is to provide a dedicated domain space in which Google can enact second-level domains specific to its projects in development. Specifically, the new gTLD will provide Google with greater ability to create a custom portal for employees to manage products and services in development.
> Charleston Road Registry believes that given its intended use by Google, the .dev gTLD will best add value to the gTLD space by remaining completely closed for the sole use of Google.
[1]: https://gtldresult.icann.org/applicationstatus/applicationde...
Current best practice is to use a subdomain of a domain you control for internal stuff. Makes getting certs for internal hosts easier too if you can be bothered.
Especially with short hostnames like pi.lan :)
... I don't understand the issue as it is easy to change.