# Connection closed without handshake response Error when using py2neo

**URL:** <https://community.neo4j.com/t/connection-closed-without-handshake-response-error-when-using-py2neo/7857>\
**Category:** Python\
**Tags:** py2neo\
**Created:** [June 4, 2019, 11:48pm UTC](https://community.neo4j.com/t/connection-closed-without-handshake-response-error-when-using-py2neo/7857 "2019-06-04T23:48:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaron1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jaron1/32/4104_2.png) [@jaron1](https://community.neo4j.com/u/jaron1)\
**Post date:** [June 4, 2019, 11:48pm UTC](https://community.neo4j.com/t/connection-closed-without-handshake-response-error-when-using-py2neo/7857/1 "2019-06-04T23:48:50Z")

</div>

Hi there,

I am running a Neo4j Cloud VM instance of version: 3.4.12 (Enterprise).

I am facing an error when I attempt to connect to my Neo4j database via 'Bolt' protocol through py2neo v4.2 (I am building a web app that uses a Python-Flask backend server that connects with my Neo4j instance).

For example, to establish a connection, I run the following command:

```auto
from py2neo import Graph

Graph("bolt://mydomain.com:7687", auth=(NEO4J_USERNAME, NEO4J_PASSWORD), scheme='bolt', secure=True)

```

Do note that I have a custom domain attached to my server IP and I've followed the tutorial to set up an SSL certificate using LetsEncrypt following the guide at: [Getting Certificates for Neo4j with LetsEncrypt | by David Allen | Neo4j Developer Blog | Medium](https://medium.com/neo4j/getting-certificates-for-neo4j-with-letsencrypt-a8d05c415bbd)

My Python Flask server is running locally at the moment, without an SSL cert.

The command results in the following error:

```auto
Traceback (most recent call last):
  File "/venv/lib/python3.4/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/venv/lib/python3.4/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/venv/lib/python3.4/site-packages/flask_restful/ __init__.py", line 269, in error_router
    return original_handler(e)
  File "/venv/lib/python3.4/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "venv/lib/python3.4/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/venv/lib/python3.4/site-packages/flask/_compat.py", line 34, in reraise
    raise value.with_traceback(tb)
  File "/venv/lib/python3.4/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/venv/lib/python3.4/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/venv/lib/python3.4/site-packages/flask_restful/ __init__.py", line 269, in error_router
    return original_handler(e)
  File "/venv/lib/python3.4/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/venv/lib/python3.4/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/venv/lib/python3.4/site-packages/flask/_compat.py", line 34, in reraise
    raise value.with_traceback(tb)
  File "/venv/lib/python3.4/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/venv/lib/python3.4/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/venv/lib/python3.4/site-packages/flask_restful/ __init__.py", line 458, in wrapper
    resp = resource(*args, **kwargs)
  File "/venv/lib/python3.4/site-packages/flask/views.py", line 88, in view
    return self.dispatch_request(*args, **kwargs)
  File "/venv/lib/python3.4/site-packages/flask_restful/ __init__.py", line 573, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/venv/lib/python3.4/site-packages/flask_httpauth.py", line 104, in decorated
    return f(*args, **kwargs)
  File "/resources/base.py", line 20, in get
    data = graph.run(query).data()
  File "venv/lib/python3.4/site-packages/py2neo/database.py", line 526, in run
    return self.begin(autocommit=True).run(cypher, parameters, **kwparameters)
  File "/venv/lib/python3.4/site-packages/py2neo/database.py", line 805, in run
    entities=entities))
  File "/venv/lib/python3.4/site-packages/py2neo/internal/connectors.py", line 285, in run
    return self._run_1(statement, parameters, graph, keys, entities)
  File "/venv/lib/python3.4/site-packages/py2neo/internal/connectors.py", line 234, in _run_1
    cx = self.pool.acquire()
  File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 711, in acquire
    return self.acquire_direct(self.address)
  File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 604, in acquire_direct
    connection = self.connector(address, error_handler=self.connection_error_handler)
  File "/venv/lib/python3.4/site-packages/py2neo/internal/connectors.py", line 225, in connector
    return connect(address_, auth=cx_data["auth"], **kwargs)
  File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 967, in connect
    raise last_error
  File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 959, in connect
    connection = _handshake(s, resolved_address, der_encoded_server_certificate, **config)
  File "/venv/lib/python3.4/site-packages/neobolt/direct.py", line 905, in _handshake
    raise ServiceUnavailable("Connection to %r closed without handshake response" % (resolved_address,))
neobolt.exceptions.ServiceUnavailable: Connection to (*IP_ADDRESS*, 7687) closed without handshake response

```

In Chrome, I am able to use Neo4j Browser at "[https://mydomain.com:7473](https://mydomain.com:7473)" and log in successfully to "bolt://mydomain.com:7687".

To circumvent the problem, I run an HTTP connection and it works. For example:

```auto
from py2neo import Graph

Graph("http://mydomain.com:7474", auth=(NEO4J_USERNAME, NEO4J_PASSWORD))

```

Any help will be greatly appreciated! I would be happy to provide any necessary information.

Cheers!

---

<div class="post-metadata">

**Author:** ![ashwanth467](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ashwanth467/32/4212_2.png) [@ashwanth467](https://community.neo4j.com/u/ashwanth467)\
**Post date:** [September 19, 2019, 3:11am UTC](https://community.neo4j.com/t/connection-closed-without-handshake-response-error-when-using-py2neo/7857/2 "2019-09-19T03:11:49Z")

</div>

The issue still exists. Any update on this? I am stuck with this. Facing issue while establishing the connection to neo4j from docker container; while the same working properly outside.

---

<div class="post-metadata">

**Author:** ![peterliu](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/peterliu/32/14615_2.png) [@peterliu](https://community.neo4j.com/u/peterliu)\
**Post date:** [October 22, 2020, 4:48pm UTC](https://community.neo4j.com/t/connection-closed-without-handshake-response-error-when-using-py2neo/7857/3 "2020-10-22T16:48:29Z")

</div>

Same problem here... Can't find any solution on google...
