Can't run Pycharm Debugger using WSL2

I have a project that has in PostgreSQL, Celery, Redis, RabbitMQ via docker containers. I'm facing an issue with PyCharm's debugger when running a DRF project in WSL2(Ubuntu). The project runs success in normal mode, but when I start the debugger, it hangs and eventually fails with "Handshake failed" errors in the logs.

The full command executed is:

/home/myuser/myproject/venv/bin/python3.11 /home/myuser/.pycharm_helpers/pydev/pydevd.py --multiprocess --qt-support=auto --port 29781 --file /home/myuser/myproject/manage.py runserver 8000

Here’s a snippet of the PyCharm logs:

025-03-06 12:48:04,336 [6128385] WARN - #c.j.p.PythonHelpersLocator - Helpers pro root does not exist C:\Users\user\AppData\Local\Programs\PyCharm Professional\plugins\python-ce\helpers-pro 2025-03-06 12:48:04,337 [6128386] WARN - #c.j.p.PythonHelpersLocator - Helpers pro root does not exist C:\Users\user\AppData\Local\Programs\PyCharm Professional\plugins\python-ce\helpers-pro 2025-03-06 12:48:04,337 [6128386] WARN - #c.j.p.PythonHelpersLocator - Helpers pro root does not exist C:\Users\user\AppData\Local\Programs\PyCharm Professional\plugins\python-ce\helpers-pro 2025-03-06 12:48:04,338 [6128387] WARN - #c.j.p.PythonHelpersLocator - Helpers pro root does not exist C:\Users\user\AppData\Local\Programs\PyCharm Professional\plugins\python-ce\helpers-pro 2025-03-06 12:48:04,454 [6128503] INFO - #c.i.e.wsl - WSL mount root for Ubuntu is /mnt/ (done in 114 ms) 2025-03-06 12:48:04,493 [6128542] WARN - #c.i.u.Alarm - Do not create alarm without coroutineScope: com.intellij.ui.GotItTooltip.(GotItTooltip.kt:94) 2025-03-06 12:48:04,508 [6128557] INFO - #c.i.u.WinFocusStealer - Foreground lock timeout set to 0 2025-03-06 12:48:06,295 [6130344] WARN - #c.j.p.d.p.t.ClientModeDebuggerTransport - [92734501] Handshake failed 2025-03-06 12:48:11,303 [6135352] WARN - #c.j.p.d.p.t.ClientModeDebuggerTransport - [1988656345] Handshake failed 2025-03-06 12:48:11,512 [6135561] WARN - #c.j.p.d.p.t.ClientModeDebuggerTransport - [1268435274] Handshake failed 2025-03-06 12:48:14,781 [6138830] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities com.intellij.platform.workspace.jps.entities.SdkEntity to files 2025-03-06 12:48:14,784 [6138833] INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities com.intellij.platform.workspace.jps.entities.LibraryEntity to files 2025-03-06 12:48:16,305 [6140354] WARN - #c.j.p.d.p.t.ClientModeDebuggerTransport - [1988656345] Handshake failed 2025-03-06 12:48:16,515 [6140564] WARN - #c.j.p.d.p.t.ClientModeDebuggerTransport - [1268435274] Handshake failed 2025-03-06 12:48:21,309 [6145358] WARN - #c.j.p.d.p.t.ClientModeDebuggerTransport - [1988656345] Handshake failed

Configuration

PyCharm Interpreter: WSL interpreter (/home/myuser/myproject/venv/bin/python3.11)
Debugger Settings: Default (Host: localhost, Port: 29781)

WSL Network:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1280 qdisc mq state UP group default qlen 1000
inet 172.19.167.28/20 brd 172.19.175.255 scope global eth0

What I’ve Tried

Set Host to 172.19.167.28 and Port to 29781 in Run > Edit Configurations > Debugger, but it still fails. Checked Windows Firewall — no rules seem to block port 29781. Confirmed the server runs fine in normal mode and is accessible from Windows.

Suspicions

This might be a WSL 2 networking issue, as localhost on Windows doesn’t map to WSL’s network. Could it be a misconfiguration in PyCharm’s debugger or a firewall/antivirus interference?

Вернуться на верх