The number Tor transparent-proxy setups conventionally use for TransPort — not an IANA assignment and not a Tor default.
Tor's TransPort option accepts TCP connections that a firewall has transparently redirected, so traffic gets torified without the application knowing about SOCKS. Tor ships it disabled (the default is 0) and does not pick a port for you; 9040 is simply the number that torrc examples and Tor-routing gateway configurations settled on, which is why iptables/pf rules everywhere redirect to it. IANA lists 9027–9049 as Unassigned. A listener on 9040 means a Tor transparent proxy is configured on that host or gateway.
Do not expose
A reachable TransPort is an open proxy into the Tor network for anyone who can send it a redirected connection; bind it to the internal interface it is meant to serve.
$ sudo lsof -nP -iTCP:9040 -sTCP:LISTENSeen this on your network? Beige Box scans your Wi-Fi and shows every open port on every device — and its Ports tool links straight back here.
Get Beige Box →also available as JSON · Markdown
Corrections or a missing port? Reply @rimrocksystems.