By Dan Moren
June 21, 2022 9:34 AM PT
Solving a file sharing mystery: Why one Mac can’t see another
We all have those tech problems that we kind of give up on. Like an annoying rattle in the car where you can’t track down the source, you just eventually acclimate to it until it feels like that’s just the way it’s always been. (Even then, you’ll find that every once in a while it will just bug you.)
But there’s nothing more satisfying than eventually discovering the cause of one of those issues and vanquishing it for good.
In recent months, I’d run into a weird situation. My M1 MacBook Air could access my iMac just fine via file sharing in the Finder: the iMac showed up in the sidebar, I could copy files back and forth, no problems. However, doing the opposite—accessing the MacBook Air’s files from the iMac—simply didn’t work at all.
It was quite the perplexing conundrum: I checked the file sharing setup in the MacBook Air’s System Preferences and everything looked fine. I attempted the tried-and-true troubleshooting step of turning sharing off and then turning it on again (even tried it with a reboot in between, just to make sure). No dice.
It seemed like the problem was further down, at the networking level. Attempts to use the Finder’s Connect to Server option simply timed out, eventually reporting that the server wasn’t available. So I decided to check the port using the handy
nc command line tool—to wit:
nc -vz [IP address] [port number], which tells you whether or not a port is accepting connections. In this case, I was trying to connect to port 445, which is where the SMB file sharing server is listening.
Therein seemed to lie the problem. When accessed from my iMac, the connection to the Air’s port 445 timed out, even though other services, like SSH, were working fine. I eventually double-checked from my iPhone using
nc from within the iSH app and found that the connection timed out there as well, which let me conclude that it was definitely an issue with the MacBook Air—probably, I concluded, the firewall.
However, as I previously mentioned, the firewall pane in System Preferences reported that everything was hunky-dory with my file sharing connection. So clearly something had gotten screwed up, meaning it was time to delve under the hood to the command line.1
I’ve worked with firewalls via the command line on Linux systems, but I’d never attempted to interact with macOS’s built-in firewall. It took a bit of research to figure out, but eventually I located the tool I needed, the clearly named and easy to remember
/usr/libexec/ApplicationFirewall/socketfilterfw. Accept no substitutes.
From there, I added the --
listapps switch and was able to get a very well formatted and easy to read list of all the apps registering with the firewall. Wherein I found my problem: despite what System Preferences had reported,
/usr/sbin/smbd—the daemon for the SMB server—was set to block all incoming connections.
A little more poking around discovered that correcting the problem was pretty easy:
unblockapp /user/sbin/smbd. And voilà, I could once again connect to my MacBook Air and share files.
Now, how the firewall ended up in such a state is much more of a head-scratcher, but unfortunately one that will probably, not unlike how many licks it takes to get to the Tootsie Roll center of a Tootsie Pop, have to be filed under the heading of “the world may never know.”
- Also, it’s possible that I may in the interim have installed a piece of pre-release software in which there wasn’t a way to access the firewall via the GUI, but I’ll never tell. ↩
[Dan Moren is the East Coast Bureau Chief of Six Colors. You can find him on Twitter at @dmoren or reach him by email at email@example.com. His latest novel, The Nova Incident, comes out in July and is available to pre-order now, so do it!]
If you appreciate articles like this one, support us by becoming a Six Colors subscriber. Subscribers get access to an exclusive podcast, members-only stories, and a special community.