Trading Fish The website of Hector Castro

Unexpected AirPlay Interference

Last week, we onboarded a new engineer to our team. Initially, there was nothing out of the ordinary: gain access to applications, clone the repository, install dependencies, configure the database. But, when they fired up their development environment for the first time, things weren’t working as expected.

The symptoms were perplexing. The database was working perfectly. The backend server started up without complaint. The frontend also loaded just fine. But, when the frontend tried to talk to the backend, the browser’s network tab showed requests failing with little detail.

List open files

My first instinct was to check the backend logs. If the frontend was making requests, surely we’d see them hit the server? Nope. The backend logs remained unchanged after the few lines of bootup output. No incoming requests logged.

This was the first real clue. If the backend wasn’t receiving requests, something else must be intercepting them.

Time to dig deeper. We used lsof to see what was actually listening on port 5000:

$ lsof -i :5000
COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ControlCe 653 newdev   10u  IPv4 0x53fec3b819872e96      0t0  TCP *:commplex-main (LISTEN)
ControlCe 653 newdev   11u  IPv6 0xcb14109db92b71d5      0t0  TCP *:commplex-main (LISTEN)

Hmm, ControlCe? That’s not Python! What is ControlCe?

An unlikely culprit

A quick Google search led us down an unexpected path. It turns out ControlCe is short for ControlCenter, a macOS system process. Further digging revealed the specific use of port 5000 was more directly tied to the AirPlay Receiver!

Starting with macOS Monterey, Apple added a feature that allows your Mac to act as an AirPlay receiver, letting you stream content from other Apple devices. This explained why the failing requests from the frontend weren’t yielding much useful information!

Back on track

Once we identified the issue, the solution was straightforward. We navigated to:

System Settings > General > AirDrop & Handoff

From there, we unchecked AirPlay Receiver.

After disabling the service, we restarted our backend, and everything started working as expected! The frontend could reach the backend, requests succeeded, and our new engineer was finally unblocked. Mystery solved!