unable to connect to pycharm python consle

Answered

I currently update my pycharm to:

PyCharm 2020.2.1 (Professional Edition)
Build #PY-202.6948.78, built on August 25, 2020
You have a perpetual fallback license for this version
Subscription is active until September 1, 2021
Runtime version: 11.0.8+10-b944.31 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.6
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Non-Bundled Plugins: com.jetbrains.intellij.datalore
 

and now I am no longer able to connect to the python console. it just gets stuck at connecting to console.

Attached below is the error I get.

 

/opt/anaconda3/envs/tech_att_pipeline/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py --mode=client --port=51411
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 483, in <module>
pydevconsole.start_client(host, port)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 395, in start_client
client, server_transport = make_rpc_client(client_service, host, port)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_comm/pydev_rpc.py", line 11, in make_rpc_client
client_transport, server_transport = open_transports_as_client((host, port))
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_comm/pydev_transport.py", line 231, in open_transports_as_client
client_socket.connect(addr)
TimeoutError: [Errno 60] Operation timed out
Process finished with exit code 1

0
8 comments

Have you checked if this port is actually open? What is its status?

Run lsof -Pn -i4 in the terminal to check it.

0

Also, check your hosts file for any suspicious entries.
Make sure you have 127.0.0.1 localhost and not a different address for localhost.

0
Avatar
Permanently deleted user

this is the output of my host file everything seems to look right. 

##

# Host Database

#

# localhost is used to configure the loopback interface

# when the system is booting.  Do not change this entry.

##

127.0.0.1       localhost

255.255.255.255 broadcasthost

::1             localhost

# Added by Docker Desktop

# To allow the same kube context to work on the host and the container:

127.0.0.1 kubernetes.docker.internal

# End of section

 

As for when I run lsof -Pn -i4 I dont see the port in the list of open ports when I try to open the python console 

0

It means that something is blocking PyCharm from connecting.
Try disabling your antivirus/firewall.

Try removing 127.0.0.1 kubernetes.docker.internal

1
Avatar
Permanently deleted user

Sergey Karpov for some reason removing  127.0.0.1 kubernetes.docker.internal from my host file worked, thanks for your help but I feel like this is going to cause issues on when I use docker. 

0

True, it should be handled better on the IDE side. Here is a corresponding ticket https://youtrack.jetbrains.com/issue/PY-39920

There are internal comments where we discussed that we should handle the cases when localhost doesn't resolve to 127.0.0.1

0
Avatar
Permanently deleted user

Sergey Karpov thanks for all the help, much appreciated! 

0
Avatar
Permanently deleted user

I had the same problem and that worked for me too. I removed localhost note for ipv6 [::1] string and left localhost note only for the ip4 [127.0.0.1] string 

before:

user@user-li ~> cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 user-li

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 

after:

user@user-li ~> cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 user-li

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 

0

Please sign in to leave a comment.