Cannot conect to neo4j database from python

This is myy first time workign with neo4j. I have a huge graph with 500K nodes and I have to use it in a django application. I'm planning to create a neo4j database and then use neomodel for querying.

For creating the database, I have installed neo4j desktop and created a simple database and started it. Then I installed ptyhon neo4j-driver and tried to query the database. Here is a simple code block I'm using -

driver = GraphDatabase.driver(
  auth=basic_auth("neo4j", "neo4j"))

I have inserted only 1 node in the database for testing. Here is the code I'm using for querying -
with driver.session(database="neo4j") as session:

  results = session.read_transaction(
    lambda tx:
  for record in results:

Whenever I run any query, I get the following error -

ServiceUnavailable: Couldn't connect to localhost:7687 (resolved to ('',)):
Failed to establish connection to ResolvedIPv4Address(('', 7687)) (reason [Errno 111] Connection refused)

Everything works fine if I try the same using a neo4j sandbox. Can someone please help me how I get this to work without using sandbox?


Hi, this means the local neo4j server cannot be reached. Is it up and running? Can you connect to the neo4j browser at http://localhost:7474/ ?

Thank you for responding.
I think the problem is due to WSL2 as I have installed neo4j desktop on my windows machine and then I'm accessing the database in a py srcipt that is running on unix via WSL. When I tried the same on another unix machine where both database and py script are running, everything works fine.

I see. I'm afraid I cannot help you much with this because I know little about WSL and how it's networking works...