【问题标题】:i can't connect to localhost:7474/db/data for create a graphDatabaseService我无法连接到 localhost:7474/db/data 来创建 graphDatabaseService
【发布时间】:2013-04-13 02:25:56
【问题描述】:

我是 neo4j 的新手,编写此代码时出现以下错误:

>>> from py2neo import neo4j
>>> graph_DB = neo4j.GraphDatabaseService ("http://localhost:7474/db/data")

Traceback (most recent call last):
   File "<pyshell#1>", line 1, in <module>
      graph_DB = neo4j.GraphDatabaseService ("http://localhost:7474/db/data")
   File "C:\Python27\lib\site-packages\py2neo\neo4j.py", line 557, in __init__
      rs = self._send(rest.Request(self, "GET", self._uri))
   File "C:\Python27\lib\site-packages\py2neo\rest.py", line 372, in _send
      raise SocketError(err)
SocketError: error(10061, 'No connection could be made because the target machine actively refused it')

我使用的是 windows 7。我做了几次搜索,发现我必须打开端口 7474 才能在 具有高级安全性的 windows 防火墙中使用它 但是当我在 inbound 中创建新规则时规则 这不会影响该端口。同样在 ubuntu 10.10 中,我无法使用 netcat 打开端口:

nc -l 7474

我哪里错了?谢谢

【问题讨论】:

  • 您可能有一个(非常)严格的本地防火墙。在 Ubuntu 上尝试 telnet localhost 7474。我不知道你应该在 Windows 上做什么。
  • Connecting To localhost...无法打开与主机的连接,在端口 7474:连接失败
  • 这意味着在给定主机 (localhost) 上的端口 7474 上没有任何接受连接。 IE。 SocketError 可能是正确的。
  • 那么我该如何在代码中纠正这个问题?
  • 对不起,如果您有本地防火墙阻止它,我所说的不正确。有关详细信息,请参阅 What can be the reasons of connection refused errors? - Here's an example 如果它有效会发生什么。

标签: sockets python-2.7 port neo4j py2neo


【解决方案1】:

默认情况下,Neo4J 将访问限制为仅 127.0.0.1 (localhost),但是,您可以更改此选项。在“conf”文件夹中找到“neo4j-server.properties”并用记事本打开这个文件。

查找以下内容:

# Let the webserver only listen on the specified IP. Default is localhost (only
# accept local connections). Uncomment to allow any connection. Please see the
# security section in the neo4j manual before modifying this.
# org.neo4j.server.webserver.address=0.0.0.0

取消注释最后一行(删除 # 符号)以允许从任何地方访问 (0.0.0.0)。 (可选)将 IP 设置为仅允许从您的 Web 服务器访问。

【讨论】:

  • 这是第 3 版 neo4j.conf 中的 dbms.connector.http.address=0.0.0.0:7474
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-01-16
  • 1970-01-01
  • 2017-02-09
  • 1970-01-01
  • 1970-01-01
  • 2011-08-06
  • 1970-01-01
相关资源
最近更新 更多