# Does neo4j work with WSL2?

**URL:** <https://community.neo4j.com/t/does-neo4j-work-with-wsl2/20678>\
**Category:** Desktop\
**Created:** [June 27, 2020, 10:24am UTC](https://community.neo4j.com/t/does-neo4j-work-with-wsl2/20678 "2020-06-27T10:24:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![and\_manousakis](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/and_manousakis/32/11628_2.png) [@and\_manousakis](https://community.neo4j.com/u/and_manousakis)\
**Post date:** [June 27, 2020, 10:24am UTC](https://community.neo4j.com/t/does-neo4j-work-with-wsl2/20678/1 "2020-06-27T10:24:58Z")

</div>

Hi everyone!

**The problem:** I get an errno 111: no connection between the python client and the activated neo4j graph db. Same situation with both py2neo and neo4j python driver

**The setup:** WSL2 (build 4.19.121.1) with Ubuntu 18.04 LTS, on windows 10 Pro insider preview (build 20152.rs\_prelease.200617-1502)

On WSL2, a conda env was created with py2neo, rapidsai, etc. On windows, neo4j and pycharm are installed. The code is written in pycharm and as an interpreter I use the conda env from WSL2. However, every time I'm trying to run a query, I get an errno 111 error message. Queries from the neo4j interface run smoothly.

**The code:**

> 1. `graph = Graph("bolt://localhost:7687", auth=("user", "pass"), max_connection_lifetime=200)`
> 2. `q1 = """ CALL apoc.periodic.iterate( "MATCH (n:Person) RETURN n", "DETACH DELETE n", {batchSize:1000})`  
> """
> 3. `output = graph.run(q1).to_data_frame()`

The problem appears in line 3. What would cause this issue?

Neo4j desktop 1.2.9  
DB version: 3.5.17 and 3.5.19 were tried

Thanks!  
Andreas

---

<div class="post-metadata">

**Author:** ![webtic](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/webtic/32/7612_2.png) [@webtic](https://community.neo4j.com/u/webtic)\
**Post date:** [June 28, 2020, 10:13am UTC](https://community.neo4j.com/t/does-neo4j-work-with-wsl2/20678/2 "2020-06-28T10:13:26Z")

</div>

Sounds like there is some sort of connectivity issue.

Do I understand it correctly if I think the database is running natively in Windows and your script in the WSL environment?

Not familiar with WSL at all but I would suspect that the localhost of WSL is a different one than the windows environment. Perhaps I am completely wrong though, haven't seen Windows from up close for over 15 years.

However that 111 error is a Python connection error, I would dig into that direction.

---

<div class="post-metadata">

**Author:** ![FrederickEngelhardt](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/frederickengelhardt/32/15870_2.png) [@FrederickEngelhardt](https://community.neo4j.com/u/FrederickEngelhardt)\
**Post date:** [January 3, 2021, 5:32pm UTC](https://community.neo4j.com/t/does-neo4j-work-with-wsl2/20678/3 "2021-01-03T17:32:56Z")

</div>

WSL works with a **neo4j docker instance**.

_It does not work with Neo4j desktop instances_. Not sure why it fails even with all of the configuration matching for the docker image. Probably something related to the bolt protocol.

Steps to get it working

1. Install docker and make sure WSL support is enabled
2. Have a neo4j docker instance `docker pull neo4j:latest`

Run this in docker to connect your WSL ports correctly.

```auto
# This script spins up a docker instance

INSTANCE_NAME="neo4j-server"
PASSWORD="your-password"

docker run \
--name $INSTANCE_NAME \
-p7474:7474 -p7687:7687 \
--env NEO4J_dbms_connector_https_advertised__address="localhost:7473" \
--env NEO4J_dbms_connector_http_advertised__address="localhost:7474" \
--env NEO4J_dbms_connector_bolt_advertised__address="localhost:7687" \
--env NEO4J_AUTH=neo4j/$PASSWORD \
neo4j:latest

```

1. Connect to localhost with your WSL server and it should resolve correctly.

---

<div class="post-metadata">

**Author:** ![clem](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/clem/32/4364_2.png) [@clem](https://community.neo4j.com/u/clem)\
**Post date:** [January 4, 2021, 3:00am UTC](https://community.neo4j.com/t/does-neo4j-work-with-wsl2/20678/4 "2021-01-04T03:00:45Z")

</div>

Errno 111 is "Connection refused". So, my guess is there is some permissions problem, such that the DB is not happy with the client that's trying to connect to it.

Maybe bad config or bad username/password?

---

<div class="post-metadata">

**Author:** ![dominicvivek06](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dominicvivek06/32/5034_2.png) [@dominicvivek06](https://community.neo4j.com/u/dominicvivek06)\
**Post date:** [January 6, 2021, 5:37pm UTC](https://community.neo4j.com/t/does-neo4j-work-with-wsl2/20678/5 "2021-01-06T17:37:47Z")

</div>

Hi @and_manousakis, at which environment you are getting this error ? on the WSL2 or on Windows ? Also, you mentioned py2neo is installed only in conda, but I am sure you have already installed in windows also.

Also, since you mentioned WSL2, I believe you have docker also installed. So, follow @FrederickEngelhardt steps, but be sure to mount the volume to persist the data. Since you are using Neo4j 3.5, feel free to download my image and the docker-compose file

> **[Neo4j Spatial Docker - Dominic KUMAR's blog](https://www.dominickumar.com/blog/neo4j-spatial-docker/)**
>
> Docker Hub Starting from Neo4j 4.x, the Neo4j Spatial plugin is incompatible and it will fail to start the database. So, I have a created an Docker image that creates a Neo4j 3.5.25 image along with all the plugins that are required for Spatial...

Let me know if you need further assistance.

---

<div class="post-metadata">

**Author:** ![and\_manousakis](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/and_manousakis/32/11628_2.png) [@and\_manousakis](https://community.neo4j.com/u/and_manousakis)\
**Post date:** [January 9, 2021, 1:23pm UTC](https://community.neo4j.com/t/does-neo4j-work-with-wsl2/20678/6 "2021-01-09T13:23:53Z")

</div>

Hi @FrederickEngelhardt, thanks for the answer! I would try your suggestion if I hadn't switched to linux.

In case I switch back to that setup I'll give it a try :)
