本地运行项目成功 ,但在服务器运行程序就会报Failed to establish a new connection: [Errno -2] Name or service not known
2023-09-27 14:25:18 时间
equests.exceptions.ConnectionError: HTTPSConnectionPool(host='appapi.xxxx.com', port=443): Max retries exceeded with url: /appapi/exchange/19/v1/prolist (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fca889818d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
排查request连接 错误 ,说明是和网络 相关的,
step1:先在服务器端ping 一下测试网址的host
(automationVenv) [root@67 automationTest]# ping appapi.xxx.com PING appapi.5i5j.com.wswebpic.com (103.254.190.254) 56(84) bytes of data. 64 bytes from 103.254.190.254 (xxx.254.190.254): icmp_seq=1 ttl=55 time=2.93 ms 64 bytes from 103.254.190.254 (xxx.254.190.254): icmp_seq=2 ttl=55 time=2.56 ms 64 bytes from 103.254.190.254 (xxx.254.190.254): icmp_seq=3 ttl=55 time=4.97 ms 64 bytes from 103.254.190.254 (xxx.254.190.254): icmp_seq=4 ttl=55 time=3.07 ms
step2:在本地ping 一下测试网址的host
wangju@wangju-HP-348-G4:~$ ping appapi.xxx.com PING appapi.xxx.com (47.95.31.237) 56(84) bytes of data. 64 bytes from 47.95.31.237 (47.95.31.237): icmp_seq=1 ttl=91 time=5.18 ms 64 bytes from 47.95.31.237 (47.95.31.237): icmp_seq=2 ttl=91 time=3.94 ms ^C --- appapi.xxx.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 3.948/4.567/5.186/0.619 ms
观查到服务端和本地 同一host指向的ip不一样
解决 办法 就是在服务器端 配置被测网址的host与本地一样
nano /etc/hosts
增加内容如下:
47.95.31.237 appapi.xxx.com
再次运行脚本就可以正常执行了
相关文章
- 使用 Git 同步时出现gnutls_handshake() failed: Error in the pull function
- 解决错误 sh: 0: getcwd() failed: No such file or directory
- Android 安装APP 失败 INSTALL_FAILED_TEST_ONLY
- Nignx出现failed (3: The system cannot find the path specified)问题
- android常见错误--INSTALL_FAILED_DEXOPT
- Android studio的错误:radle sync failed: Cause: failed to find target android-21 :
- failed to create process怎么解决
- SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"
- Can not evaluate the expression: Back-end (JVM) Internal error: Failed to generate expression: KtLam
- 记录实验室深度学习服务器显卡硬件故障的排查——RmInitAdapter failed! rm_init_adapter failed
- SpringBoot配置了数据库依赖 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe
- maven tomcat插件上传项目到tomcat服务器报错SEVERE: One or more listeners failed to start.
- qiankun常见问题集合:主子应用间路由跳转、微应用如何设置跨域访问、各生命周期钩子如何执行、应用内路由跳转报错:Failed to execute 'replace' on 'Location'
- Gson本地和服务器环境不同遇到的Date转换问题 Failed to parse date []: Invalid time zone indicator
- Linux下使用docker 拉取 vsftpd 镜像搭建 Ftp 服务器,连接 Ftp 时遇到的错误(425 Failed to establish connection)
- AndroidStudio编译项目显示 error: failed linking file resources. 出现的原因及其解决方案