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:

  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 ?


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

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 ="MATCH (n:Movie) RETURN n.title LIMIT 3")

It worked and 3 titles were displayed.

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!

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

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.

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?


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

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

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.