Unable to setup remote Java debugging on macOS: connection refused

Answered

This is not an IDEA problem, but I'm hoping that someone else has enountered the problem and found a solution.

I am trying to setup remote Java debugging between two machines running macOS.

I am able to get the Java program to listen on a socket. However, I can connect to that socket only from the same machine, not from another machine on my local network. I use nc to test the connection. It reports Connection refused when trying to connect from the other machine.

This issue sounds like it could be caused by the Java program lacking Local Network system permission. I am familiar with that issue arising when a program attempts to connect to a port on the local network. In that case, a dialog is displayed and System Settings can be used to grant Local Network permission to the client program. I don't know whether the same permission is required on the program that is *receiving* client requests. If it is, then I don't know how to grant that permission. There is no dialog, and System Settings does not provide any obvious way to grant permission to a program that I specify.

I am running macOS 15.6 and 26.

0
8 comments

I forgot to mention that the firewall is not turned on.

0
I'd use Wireshark to capture a network trace while reproducing the issue to understand the context from network perspective.
https://www.wireshark.org/#download
0

I ran Wireshark but I have no idea what the output means.

nc -v mac-mini.local 5005
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused
nc: connectx to mac-mini.local port 5005 (tcp) failed: Connection refused


 

 

0
Which IP did you bind to the running service? What if you use an actual IP instead of "mac-mini.local" the host name to perform the nc command? It looks strange to try to connect to another machine using something local as the host name. Also the network trace seems indicating that the host is reachable but either the port is not listening or the firewall refused it.
0

If I specify an IP address, nc still fails but only once.

```

nc: connectx to 192.168.0.31 port 5005 (tcp) failed: Connection refused

```

The firewall is not enabled.

 

0
Then it doesn't look like a permission issue as it only fails for the first time I suppose. I'd suggest you to post it in SO or other channels to seek advice from the macOS perspective.
0

It turned out to be my mistake, caused by using an old script.

The command line argument needs to contain `address=*:5005`, not `address=5005`.

 

 

0

Please sign in to leave a comment.