1

我是 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 防火墙中使用它,但是当我在入站规则中创建新规则时,这不会影响该端口。同样在 ubuntu 10.10 中,我无法使用netcat打开端口:

nc -l 7474

我哪里错了?谢谢你

4

1 回答 1

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 服务器进行访问。

于 2014-11-10T16:44:41.693 回答