Check your security settings / local network and make sure that whatever dev app you are using has access enabled.
Note: this is independent of the macOS firewall settings, and will still block traffic even if firewall is off.
I temporarily deactivated the global firewall and (in my case VScode) still wouldn’t connect to a machine on my local network, until I manually enabled local network access. Pinging Google etc was just peachy though, so it made for some baffling early investigations.