【发布时间】: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 是
ENOEXEC。gethostbyname_ex或gethostname没有明显的原因会因该错误而失败。什么操作系统?如果是 linux,我会做一个strace <your program>并尝试确定实际生成该 errno 的系统调用。 -
我使用的是 Mac。不幸的是,我不知道 mac 中有 strace 副本。
-
我在mac上编程不多,但看起来
dtruss是等价的。