I am using JetBrains Pycharm IDE in ubuntu 18.04

when I am hitting run, it is working fine but debugging is failing every time with the following error.

error screenshot

and this is prompt from debug button

Connection to Python debugger failed Socket closed

I tried these, but couldn't make it work :

  1. uninstalling pycharm

  2. editing interpreter location

  3. removing virtual environment

  4. tried changing debugger port

this is my configuration file

configuration details

please help me with this issue

6 Answers 6


After a hell lot of searching and experimenting, found the solution for my issue.

My repo consists of a module named code in it. Similarly, python has a same-named module for debugging, which creating a clash and debugger unable to reach that code.

I renamed it, and it's working like charm now. Had similar issue with 'test' as a module name

  • 1
    I can confirm this. On my end I was working through the code examples from Brian Okken's 'Python Testing with Pytest'. The root directory for the provided code examples was named 'code'. I changed that to 'code-book', and debugging via Pytest in PyCharm now works as it should.
    – xax
    Sep 2, 2019 at 2:46

I had/have Python Community Edition (2019.1.1, now 2019.3.3) installed on Windows laptop. I named a new file "String". It took some time before I realized it was the name which caused the debugger to fail. The message I received was "connection to python debugger failed interrupted function call accept failed" . The failure was caused solely by the improper naming of the file. I tested again on version 2019.3.3, the name "string" causes the same failure of the debugger to connect and connection is fine when I change the file name to something else.


Got the same issue on Pycharm Professional 2021.1 on Windows, because of a file I named types.py,

renaming it got the debugger to run.

  • same on Linux Mint. Guess it is not related to the OS.
    – Christian
    Oct 19, 2021 at 3:34

I think, the issue of problem is due to "Project" relation. I have confused about debugging trouble. At a moment, I could'nt using the Debug tool in PyCharm, I used to it well before. There are some different about the Project characterization between "PyCharmProjects" and "PythonProject". If you used "PyCharmProjects" at first, it is no trouble. Later you may create new project as "PythonProject", you wouldn't using debug tool in PyCharm. This is in my case, I hope someone get help from this hint.


I had to rename a file named "site.py" to something else to get my debugger to work again.


I had to rename a file named "inspect.py" to something else to get my debugger to work again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.