Working with Rust on Macbook M3 - networking issues

I am looking for help developing in Rust on a Macbook M3. I have been assigned this laptop for work and I am used to working on Linux. To be honest, I'm hating this Mac and it's making a challenging new job much harder.

I have a test that fails locally on M3 but that passes on my Linux laptop (thankfully at least this project is open source so I can check it out to my own laptop). The test uses a run_server function from an imported dependency, listening on 0.0.0.0 and that is a hardcoded configuration that I don't want to have to change. The test runs normally up to a failing assertion that a value should have been updated after connecting to the server.

Does anybody who uses an M3 for their work have a list of what needs to be added to Network > Firewall options to allow incoming connections?

I found MacOS firewall settings tools for Node users, but I wish I could find someone using Rust who understands and knows how to solve my issue.

So far, adding the executables created when I run cargo test --no-run to the "allow incoming connections" list in Firewall options has not fixed my issue.

The IT department sets the profiles and so I'm restricted from enabling and accessing the logs for the firewall while my test runs. So far nobody is able to help me and my teammates - for whatever reason - have Linux laptops while I (basically the first new guy for a long time) was assigned this M3 without being asked ...

If anyone could help it would really make my day as I'm behind and feeling defeated by this.

If you have at least local root access, you can use tcpdump and dtrace to diagnose the connection issues.

My first suspicion is that when the client looks up localhost, for instance, it may be given (or prefer) the IPv6 address ::1 which does not map to IPv4 0.0.0.0. I've been bitten by this a few times on all major platforms.

This question is completely unrelated to Rust, by the way.

1 Like

Thanks for the suggestions, especially about IPv6. Does that mean that if I forked the dependency and changed 0.0.0.0 to [::] this would test whether that was the issue?

I kind of knew this wasn't a Rust-specific thing, but also wondered whether adding certain things like Cargo, for example, to the networking/firewall whitelists might help me.

Edit: forking the dependency and changing 0.0.0.0 to [::] worked. So thank you so much!

You can also just use non-Rust tools to verify:

Start a server listening on 0.0.0.0:

nc -l 0.0.0.0 8000

Send something to the server:

echo "this won't work" | nc ::1 8000

echo "this works" | nc 127.0.0.1 8000
2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.