zoukankan      html  css  js  c++  java
  • 本地运行项目成功 ,但在服务器运行程序就会报Failed to establish a new connection: [Errno -2] Name or service not known

    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



    再次运行脚本就可以正常执行了

  • 相关阅读:
    编辑语言发展历史
    正则表达式
    css
    伪类和伪元素区别
    WEB 之API端口
    event flow (Dow)
    for衍生对象
    前端语言的发展
    document
    password user message email的正则表达式
  • 原文地址:https://www.cnblogs.com/kaerxifa/p/11039863.html
Copyright © 2011-2022 走看看