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.

Couldn't connect to localhost:7687 connection issue with Airflow

I tried to build connection between airflow in local docker and desktop Neo4j(1.5.6) database. The connection info was in Airflow Connections. This error raise:

 

neo4j.exceptions.ServiceUnavailable: Couldn't connect to localhost:7687 (resolved to ()):
Failed to establish connection to ResolvedIPv4Address(('127.0.0.1', 7687)) (reason [Errno 111] Connection refused)
Failed to establish connection to ResolvedIPv6Address(('::1', 7687, 0, 0)) (reason [Errno 99] Cannot assign requested address)
[] {taskinstance.py:1327} INFO - Marking task as FAILED. dag_id=neo4j_workflow_tutorial2, task_id=neo4j_operator_task, execution_date=20220309T053100, start_date=20230117T000651, end_date=20230117T000651
[] {standard_task_runner.py:105} ERROR - Failed to execute job 33525 for task neo4j_operator_task (Couldn't connect to localhost:7687 (resolved to ()):
Failed to establish connection to ResolvedIPv4Address(('127.0.0.1', 7687)) (reason [Errno 111] Connection refused)
Failed to establish connection to ResolvedIPv6Address(('::1', 7687, 0, 0)) (reason [Errno 99] Cannot assign requested address); 2498)
[] {local_task_job.py:159} INFO - Task exited with return code 1
[] {taskinstance.py:2582} INFO - 0 downstream tasks scheduled from follow-on schedule check

 

This is my Neo4j setting:

 

 

# Whether requests to Neo4j are authenticated.

dbms.security.auth_enabled=false

# Bolt connector
server.bolt.enabled=true
#server.bolt.tls_level=DISABLED
server.bolt.listen_address=:7687
server.bolt.advertised_address=localhost:7687

# HTTP Connector. There can be zero or one HTTP connectors.
server.http.enabled=true
#server.http.listen_address=:7474
#server.http.advertised_address=:7474

# HTTPS Connector. There can be zero or one HTTPS connectors.
server.https.enabled=false
#server.https.listen_address=:7473
#server.https.advertised_address=:7473

Tried many solutions from other posts which have similar problems, but still not work for me. Can anyone please help with this?

2 REPLIES 2

For testing, I have a springboot application running in a docker container and neo4j in a docker container, both running locally. I was not able to get the springboot application to connect to the the neo4j server using the localhost:7687 uri.  It turns out that this directs docker to look within the internal network of the container. I found changing the uri to the following, which resulted in getting a connection to the neo4j database: 

host.docker.internal:7687

Thanks a lot, it works when I use host: "host.docker.internal" and also using connection ui on airflow instead of backend file and variable UI to set the parameters.