Swaraj Raibagi
Swaraj Raibagi

Reputation: 21

ISSUE IN CONNECTING py2neo v4 to my neo4j server

I want to connect my neo4j's project server to py2neo in jupyter I actually have 2 problems: Given below is a picture of my neo4j browser connected with bolt//:localhost:11004, username: neo4j, password: password But i am not able to connect to this server through py2neo on jupyter notebook. The code in python is the following: graphdb = Graph("bolt://localhost:11004", secure=True, auth=('neo4j', 'password')) I am getting the following error:

KeyError                                  Traceback (most recent call last)
~/conda3/lib/python3.6/site-packages/py2neo/database.py in __new__(cls, uri, **settings)
     87         try:
---> 88             inst = cls._instances[key]
     89         except KeyError:

KeyError: '0611fb007d1a660e26e66e58777225de'

During handling of the above exception, another exception occurred:

ServiceUnavailable                        Traceback (most recent call last)
<ipython-input-41-2d6567e9c5ba> in <module>()
      3 # default uri for local Neo4j instance
      4 dict_params=dict(secure=True)
----> 5 graphdb = Graph(**dict_params)

~/conda3/lib/python3.6/site-packages/py2neo/database.py in __new__(cls, uri, **settings)
    303     def __new__(cls, uri=None, **settings):
    304         name = settings.pop("name", "data")
--> 305         database = Database(uri, **settings)
    306         if name in database:
    307             inst = database[name]

~/conda3/lib/python3.6/site-packages/py2neo/database.py in __new__(cls, uri, **settings)
     95                                   auth=connection_data["auth"],
     96                                   encrypted=connection_data["secure"],
---> 97                                   user_agent=connection_data["user_agent"])
     98             inst._graphs = {}
     99             cls._instances[key] = inst

~/conda3/lib/python3.6/site-packages/neo4j/v1/api.py in __new__(cls, uri, **config)
    131         for subclass in Driver.__subclasses__():
    132             if parsed.scheme == subclass.uri_scheme:
--> 133                 return subclass(uri, **config)
    134         raise ValueError("URI scheme %r not supported" % parsed.scheme)
    135 

~/conda3/lib/python3.6/site-packages/neo4j/v1/direct.py in __new__(cls, uri, **config)
     71 
     72         pool = DirectConnectionPool(connector, instance.address, **config)
---> 73         pool.release(pool.acquire())
     74         instance._pool = pool
     75         instance._max_retry_time = config.get("max_retry_time", default_config["max_retry_time"])

~/conda3/lib/python3.6/site-packages/neo4j/v1/direct.py in acquire(self, access_mode)
     42 
     43     def acquire(self, access_mode=None):
---> 44         return self.acquire_direct(self.address)
     45 
     46 

~/conda3/lib/python3.6/site-packages/neo4j/bolt/connection.py in acquire_direct(self, address)
    448                 if can_create_new_connection:
    449                     try:
--> 450                         connection = self.connector(address, self.connection_error_handler)
    451                     except ServiceUnavailable:
    452                         self.remove(address)

~/conda3/lib/python3.6/site-packages/neo4j/v1/direct.py in connector(address, error_handler)
     68 
     69         def connector(address, error_handler):
---> 70             return connect(address, security_plan.ssl_context, error_handler, **config)
     71 
     72         pool = DirectConnectionPool(connector, instance.address, **config)

~/conda3/lib/python3.6/site-packages/neo4j/bolt/connection.py in connect(address, ssl_context, error_handler, **config)
    702         raise ServiceUnavailable("Failed to resolve addresses for %s" % address)
    703     else:
--> 704         raise last_error

~/conda3/lib/python3.6/site-packages/neo4j/bolt/connection.py in connect(address, ssl_context, error_handler, **config)
    692         log_debug("~~ [RESOLVED] %s -> %s", address, resolved_address)
    693         try:
--> 694             s = _connect(resolved_address, **config)
    695             s, der_encoded_server_certificate = _secure(s, address[0], ssl_context, **config)
    696             connection = _handshake(s, resolved_address, der_encoded_server_certificate, error_handler, **config)

~/conda3/lib/python3.6/site-packages/neo4j/bolt/connection.py in _connect(resolved_address, **config)
    582         _force_close(s)
    583         if error.errno in (61, 99, 111, 10061):
--> 584             raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved_address, error.errno))
    585         else:
    586             raise

ServiceUnavailable: Failed to establish connection to ('127.0.0.1', 7687) (reason 111)

What i want to know is 1) The connection between neo4j and py2neo is made how exactly in py2neo v4 2) Do i always have to make a local connection or can i connect to the neo4j server 3) If i can connect to my neo4j server is it such that whatever py2neo queries i run on my jupyter notebook shall synchronise with the neo4j database too?

Upvotes: 2

Views: 5292

Answers (1)

Rajendra Kadam
Rajendra Kadam

Reputation: 4052

From the last line of the error, it looks like it's trying to connect on default bolt port (i.e. 7687).

I would suggest you use this format instead of full URI.

graphdb = Graph(scheme="bolt", host="localhost", port=11004,
secure=True, auth=('neo4j', 'password'))

Upvotes: 1

Related Questions