【问题标题】:socket.gaierror while connecting to remote server连接到远程服务器时的socket.gaierror
【发布时间】:2016-06-24 04:02:47
【问题描述】:

我正在尝试按如下方式连接到远程数据库:

with SSHTunnelForwarder(
    ssh_address=('10.160.1.24', 22),
    ssh_username='Administrator',
    ssh_password=ssh_password,
    remote_bind_address=('127.0.0.1', 5432)) as server:
    print("test")

但是我遇到了这个错误:

remote_bind_address=('127.0.0.1', 5432)) as server:
  File "/Library/Python/2.7/site-packages/sshtunnel.py", line 879, in __init__
    self._local_interfaces = self._get_local_interfaces()
  File "/Library/Python/2.7/site-packages/sshtunnel.py", line 1378, in _get_local_interfaces
    local_if = socket.gethostbyname_ex(socket.gethostname())[-1]
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

【问题讨论】:

  • 对我也没有任何意义。 Errno 8 是ENOEXECgethostbyname_exgethostname 没有明显的原因会因该错误而失败。什么操作系统?如果是 linux,我会做一个 strace <your program> 并尝试确定实际生成该 errno 的系统调用。
  • 我使用的是 Mac。不幸的是,我不知道 mac 中有 strace 副本。
  • 我在mac上编程不多,但看起来dtruss是等价的。

标签: python sockets ssh proxy


【解决方案1】:

问题是因为缺少 local_bind_address 参数。该方法似乎需要此参数,即使它是可选的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-22
    • 2017-09-16
    • 2012-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多