15

PyCharm remote debugging (pydevd) does not connect with the following message:

error: [Errno 10061] No connection could be made because the target machine actively refused it

How can I troubleshoot it?

The output console in PyCharm shows:

Starting debug server at port 21000
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('*.*.*.*', port=21000, suspend=False)
Waiting for process connection...
Server stopped.

I checked the firewall and PyCharm is allowed for both incoming and outgoing connections.

John Moutafis
  • 18,296
  • 5
  • 55
  • 96
denfromufa
  • 4,995
  • 11
  • 66
  • 130
  • Which OS? Your PyCharm version? – MaxVT Sep 02 '15 at 20:46
  • Win 7, Pycharm 4.5.4 Pro – denfromufa Sep 02 '15 at 20:57
  • How 'remote' is this machine? Are you trying to debug code inside a virtual machine by any chance? – vlad-ardelean Sep 17 '15 at 11:52
  • @denfromufa have you managed to solve this? – Or Duan Sep 07 '16 at 17:03
  • 1
    still open: https://youtrack.jetbrains.com/issue/PY-16844 – denfromufa Sep 07 '16 at 17:09
  • 4
    Have you checked that port 21000 has something listening and that you have pydevd setup at the other end ? – Amias Nov 01 '16 at 07:15
  • You can check is something is on port 21000 by telnet-ing to that port in console like "telnet localhost 21000". – Rok Jaklič Jan 06 '17 at 11:51
  • You can use netstat, which works also on Windows - https://technet.microsoft.com/pl-pl/library/bb490947.aspx - to check if port is open. My guess is that you are querying wrong interface... For instance - debug is open on localhost, while you are trying to connect to your network interface. That way system will kick your request off. – Michał Zaborowski Jan 14 '17 at 17:14
  • What is Your target OS? Fedora, CentOS has a selinux which can see this activity as a thread. If this connection not working and You're sure about pycharm Debug service is up and running on 21000, You may disable selinux and give a second try. – Joepreludian Jun 05 '17 at 15:38
  • both host and guest were windows 7 – denfromufa Jun 05 '17 at 15:59
  • I tried several times do do a remote debug on Windows (Windows as target) and failed every time. While debugging remotely to Linux works flawlessly, I couldn't get it to work on Win. Did you manage to locate python.exe from PyCharm? Are you using PyCharm Pro? – Artur Jun 12 '17 at 12:07
  • Like @vlad-ardelean asked: Is the any maschine (host or guest) a VM? If so, the VM gets by NAT a new port range as the pure "host" maschine. You should then try bridge network mode. – zypro Aug 01 '17 at 05:37

3 Answers3

2

10061 is WSAECONNREFUSED, 'connection refused', which means there was nothing listening at the IP:port you tried to connect to.

Though I see that you have validated its not a firewall issue, but still I would suggest to check the port numbers again with respect to the ones opened in windows firewall. Or to narrow down just run a simplehttpserver or icmp server at the same port and confirm.

Surjit R
  • 146
  • 4
1

In a direct link communication, it often means that you have already something connected to this port. To check what process is hearing what port, check this SO question.
You can then either kill the program or change the port, depending of what you can do.
Without more information of the "remote tested", it is hard to know what is happening.

Ludovic Guerra
  • 350
  • 1
  • 12
1

I was having the trouble as well (Server stopped as soon as the client connected).

Turned out that I had apparently too many breakpoints defined.

after having removed most of them and re-initiated my remote debug connection from the client (and having restarted the debug server in pycharm) it doesn't trigger anymore the "Server stopped." problem.

gst
  • 369
  • 1
  • 3
  • 15