我无法连接到localhost:7474 / db / data用于创建graphDatabaseService

时间:2013-04-19 16:08:20

标签: sockets python-2.7 port neo4j py2neo

当我编写此代码时,我是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

我哪里错了?谢谢

1 个答案:

答案 0 :(得分: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

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