cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Accessing Neo4j using py2neo

I have tried accessing my neo4j graph database through Jupyter Notebook and VSCode using both py2neo and GraphDatabase drivers.

Somehow it always says connection not found. I am using Neo4j desktop, and starting the local dbms and neo4j browser. When I try either:

  1. Session.run()
  2. Graph("bolt://localhost:7687", auth = ("neo4j","password"))
    It shows connection is closed or not established. I have tried reading through so many resources but there is no clear and concise correction. I read somewhere that the neo4j instance has to run on the same server as the python code - but how does this work and what can I do to rectify this problem ?
1 ACCEPTED SOLUTION

I resolved the error somehow. The password was indeed "password" but I don't know why it wasn't working. However, when I open the browser through the http protocol in safari, it started working.
Strange!

View solution in original post

8 REPLIES 8

andy_hegedus
Graph Fellow

Hi,

Maybe a silly question, but are you sure the database is running?
Andy

Hi Andy, I am sure the database is running. I have the neo4j browser open and it shows connected as well

Hi @parthiv3215

Here is my environment.

Neo4j 4.4.2
Python 3.9.9
py2neo 2021.2.3
Data Movie

Install py2neo into my project.

$ pip install py2neo

I created a simple code.

from py2neo import Graph
graph = Graph("bolt://localhost:7687", auth=("neo4j", "hogehoge"))
result = graph.run("MATCH (n:Movie) RETURN n.title LIMIT 3")
print(result)

It worked and 3 titles were displayed.

Dear Koji, this is the exact same thing that I tried to run. However at the graph command it shows me an error and says connection has been closed or connection unavailable. If I am not wrong all I have to do with my neo4j desktop app is start the local dbms and open the browser right? I tried editing the config file also but It didn't work.

@parthiv3215

From the error, it seems that the password is wrong.
Is the "neo4j" password "password" ?

graph = Graph("bolt://localhost:7687", auth=("neo4j", "password"))

Hey, @parthiv3215.

I have some videos showing how to use each driver in the Bite-Sized Neo4j for Data Scientists series. I also have a blog post about it that you can find here.

Good luck!

Dear Clair,

Thanks for your help. I was actually following your videos, however for some reason it didn't work. I haven't used sandbox btw, I am using desktop. Any ideas on what I can do?

I resolved the error somehow. The password was indeed "password" but I don't know why it wasn't working. However, when I open the browser through the http protocol in safari, it started working.
Strange!