Eclipse报错:cannot connect to VM

一、Windows环境:

在用eclipse debug 时忽然碰到一个错误cannot connect to VM” ,异常信息如下:
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=JVMTI_ERROR_INTERNAL(113)
ERROR: transport error 202: gethostbyname: unknown host ["transport.c",L41]
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) ["debugInit.c",L500]
JDWP exit error JVMTI_ERROR_INTERNAL(113): No transports initialized

后来终于发现问题不是处在jdk或者eclipse上,而是windows本身出了问题。

在C:\WINDOWS\system32 \drivers\etc\hosts 文件正常的情况下,ping localhost 或者ping 计算机名 系统均提示不识别,只有ping 127.0.0.1 才能ping通。

解决办法:用一个修复winsock的工具 winsockfix.exe 修复并重启后问题终于解决

二、Linux环境:

在/etc/hosts下面添加
127.0.0.1 localhost.localdomain localhost
上面一行就行了。
应该是localhost没有映射到127.0.0.1的缘故。因为eclipse调试的时候会连接localhost的.

原文地址:https://www.cnblogs.com/orientsun/p/2614616.html