My PyCharm run is working but debugging is failing

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


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


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.