当前位置: 代码迷 >> 综合 >> The Network Adapter could not establish the connection errorCode 17002, state 08006
  详细解决方案

The Network Adapter could not establish the connection errorCode 17002, state 08006

热度:32   发布时间:2024-02-06 13:22:34.0

问题说明

今天在centos7虚拟机中运行java程序,程序启动需要连接主机的oracle,报错:
The Network Adapter could not establish the connection
errorCode 17002, state 08006

意思就是网络问题无法连接!

问题排查

虚拟机中用telnet测试了一下主机的1521端口不通。

然后查看listener.ora的配置发现HOST配的是localhost
在这里插入图片描述

listener.ora的host不能是localhost,而应该是计算机名,否则不能用ip地址进行连接。
因为主机名基于NetBios和DNS协议,当监听配置文件里填的不是IP地址时,会尝试用NetBios或DNS进行解析以得到对应的IP。
所以填了localhost就只能是本地应用可以连接了!

问题解决

将listener.ora中的HOST改为计算机名,例如我的:
在这里插入图片描述
然后重启监听程序:

lsnrctl stop
lsnrctl start

虚拟机再去telnet发现通了!
在这里插入图片描述

  相关解决方案