# Neo4j GCP Deployment: WebSocket connection failure and Failed to establish connection

**URL:** <https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736>\
**Category:** Neo4j Graph Platform\
**Tags:** migrated\
**Created:** [August 6, 2022, 6:51am UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736 "2022-08-06T06:51:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![phillip\_shao\_ng](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/phillip_shao_ng/32/22396_2.png) [@phillip\_shao\_ng](https://community.neo4j.com/u/phillip_shao_ng)\
**Post date:** [August 6, 2022, 6:51am UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736/1 "2022-08-06T06:51:40Z")

</div>

Goal: Automate creating Neo4j graph database on GCP, and then connect to it using a python driver (locally and hosted on Cloud Run). I have tried to use:

1. The "[https://neo4j.com/docs/operations-manual/current/cloud-deployments/neo4j-gcp/automation-gcp/"](https://neo4j.com/docs/operations-manual/current/cloud-deployments/neo4j-gcp/automation-gcp/%22) documentation, but it lacks the ability to set configurations easily (it uses a remote cypher shell command, and I have to use a CALL function to change each configuration.)
2. The Docker Image using GCP's deployment from container images: [https://cloud.google.com/compute/docs/containers/deploying-containers#gcloud](https://cloud.google.com/compute/docs/containers/deploying-containers#gcloud). This is a preferred method since all configurations can be set using ENV variables.

I have had success with starting a neo4j database using a docker image. In order to test the bolt connection, I go to [https://browser.neo4j.io/](https://browser.neo4j.io/) and put in the external IP address of the VM, and try to connect. However, I get the error:

WebSocket connection failure.  
Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver.  
Please use your browsers development console to determine the root cause of the failure.  
Common reasons include the database being unavailable, using the wrong connection URL or temporary network problems.  
If you have enabled encryption, ensure your browser is configured to trust the certificate Neo4j is configured to use.  
WebSocket readyState is: 3

When I use the python driver to connect to the VM, I get the error:

Failed to establish connection to ResolvedIPv4Address(('35.225.230.248', 7687)) (reason [Errno 61] Connection refused))

These are the environmental variables I've set:

NEO4J\_dbms\_default\_\_listen\_\_address=0.0.0.0

NEO4J\_dbms\_connector\_bolt\_listen\_\_address=0.0.0.0:7687

NEO4J\_dbms\_connector\_bolt\_address=0.0.0.0:7687

NEO4J\_dbms\_connector\_bolt\_tls\_\_level=OPTIONAL

I have configured GCP's firewall to allow the BOLT port.

![phillip_shao_ng_0-1659768580948.png](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/e/5/e577b563409634bd14a8a9bcace2608836026659.png "phillip\_shao\_ng\_0-1659768580948.png")

I've reference all of the articles out there that have addressed this problem to no avail:

[https://community.neo4j.com/t5/neo4j-graph-platform/explanation-of-error-quot-websocket-connection-failure-due-to/m-p/36473](https://community.neo4j.com/t5/neo4j-graph-platform/explanation-of-error-quot-websocket-connection-failure-due-to/m-p/36473)

[https://medium.com/neo4j/getting-certificates-for-neo4j-with-letsencrypt-a8d05c415bbd](https://medium.com/neo4j/getting-certificates-for-neo4j-with-letsencrypt-a8d05c415bbd)

[https://stackoverflow.com/questions/70424753/serviceunavailable-websocket-connection-failure-after-server-connect-for-neo4j](https://stackoverflow.com/questions/70424753/serviceunavailable-websocket-connection-failure-after-server-connect-for-neo4j)

---

<div class="post-metadata">

**Author:** ![david\_rosenblum](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/david_rosenblum/32/4883_2.png) [@david\_rosenblum](https://community.neo4j.com/u/david_rosenblum)\
**Post date:** [August 9, 2022, 4:22pm UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736/2 "2022-08-09T16:22:19Z")

</div>

I did launch a docker the same way - you can't use [https://browser.neo4j.io/](https://browser.neo4j.io/?_gl=1*sfnscg*_ga*MTAyNjk5NzQ1OS4xNjUyODc5NTI3*_ga_DL38Q8KGQC*MTY2MDA2MDUwNS4yNy4xLjE2NjAwNjE4NTcuMA..) on an instance without SSL setup. This is a restriction in the Web Browser standard, not Neo4j.  
Setting TLS optional is not sufficient - you will need to do the whole get a cert, etc.  
SO get rid of the env NEO4J\_dbms\_connector\_bolt\_tls\_\_level=OPTIONAL

gcloud compute instances create-with-container drneodocker --container-image neo4j:4.4.9

Created [[https://www.googleapis.com/compute/v1/projects/neo4j-se-team-201905/zones/us-east1-d/instances/drneodocker](https://www.googleapis.com/compute/v1/projects/neo4j-se-team-201905/zones/us-east1-d/instances/drneodocker)].

NAME ZONE MACHINE\_TYPE PREEMPTIBLE INTERNAL\_IP EXTERNAL\_IP STATUS

drneodocker us-east1-d n1-standard-1 10.142.0.10 35.229.62.xxx RUNNING

Neo4j came right up, and I was able to hit the external address directly  
[http://35.229.62.xxx:7474/browser/](http://35.229.62.xxx:7474/browser/)

you can, tho I don't know why you would, when you can hit the http port directly - you can use [http://browser.graphapp.io](http://browser.graphapp.io) which is not SSL - your web browser may try very hard to flip that to https.  
or login directly with python on port 7687  
HTH  
David

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [August 9, 2022, 1:29pm UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736/3 "2022-08-09T13:29:10Z")

</div>

The only thing I can imagine is that the bolt port is not properly forwarded within your GCP infrastructure to the from docker to the ingress of your instance?

---

<div class="post-metadata">

**Author:** ![phillip\_shao\_ng](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/phillip_shao_ng/32/22396_2.png) [@phillip\_shao\_ng](https://community.neo4j.com/u/phillip_shao_ng)\
**Post date:** [August 9, 2022, 5:03pm UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736/4 "2022-08-09T17:03:24Z")

</div>

Hi David, thank you for your response. I was able to replicate your steps and create a Neo4j instance that connectable via browser and bolt. However, I would like to add a default password upon creation, instead of logging into the browser to change it. I was trying to add the argument to your gcloud command, --container-env=[NEO4J\_AUTH=neo4j/PASSWORD] ([https://cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container#--container-env](https://cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container#--container-env)), but it doesn't work ([https://neo4j.com/docs/operations-manual/current/docker/ref-settings/](https://neo4j.com/docs/operations-manual/current/docker/ref-settings/)). Do you know how to configure the password from the container image environment variables?

Command: gcloud compute instances create-with-container drneodocker --container-image neo4j:4.4.9 --container-env=[NEO4J\_AUTH=neo4j/PASSWORD]

---

<div class="post-metadata">

**Author:** ![david\_rosenblum](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/david_rosenblum/32/4883_2.png) [@david\_rosenblum](https://community.neo4j.com/u/david_rosenblum)\
**Post date:** [August 10, 2022, 12:37am UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736/5 "2022-08-10T00:37:15Z")

</div>

I used this  
gcloud compute instances create-with-container rosenblumdocker1 --container-image neo4j:4.4.9 --container-env=NEO4J\_AUTH=neo4j/Mypassword

I used a new container name. Once the password is set in the system db (with a permanent the disk attached) you can't change it with this method.  
I noticed that you are not using a persistent disk, if you reboot the container, all your data will be LOST

---

<div class="post-metadata">

**Author:** ![jahidmailbox98](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jahidmailbox98/32/33604_2.png) [@jahidmailbox98](https://community.neo4j.com/u/jahidmailbox98)\
**Post date:** [August 1, 2025, 1:40pm UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736/6 "2025-08-01T13:40:47Z")

</div>

Hi David,

I'm facing an issue where Neo4j works perfectly in my local development environment, but after deployment to a remote server, it fails to connect.

1. Local Setup (Works Fine)

- Protocol: bolt://host:7687

- Also tried: neo4j+s://host

- Using React frontend with Neo4j JavaScript driver

- Neo4j connects correctly in local using WebSocket fallback (ws:// or wss://)

1. Deployed Setup (Not Working)

- Frontend deployed over HTTPS in GCP Cloud run

- Neo4j backend exposed on port 7687 and also created self signed certificate

- Trying to connect using:

1. What I Tried:

- Set `REACT_APP_NEO4J_URI=neo4j+ssc://ip:7687`

- Enabled `bolt` connector in `neo4j.conf`

- Enabled SSL policies for Bolt and added certificate

- Used `trust: "TRUST_ALL_CERTIFICATES"` in driver config

- Verified server firewall is open for port `7687`

Despite trying multiple configurations, the frontend still cannot establish a WebSocket (`wss://`) connection after deployment.

Any advice on the next steps .

Thanks,  
Mohamed Jahid Ameer

---

<div class="post-metadata">

**Author:** ![david\_rosenblum](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/david_rosenblum/32/4883_2.png) [@david\_rosenblum](https://community.neo4j.com/u/david_rosenblum)\
**Post date:** [August 1, 2025, 2:42pm UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736/7 "2025-08-01T14:42:38Z")

</div>

This is most likely an SSL problem.  
You are mixing a real cert (cloud run) with a self signed certificate on neo4j. I have never had any luck mixing those with javascript driver.  
You could start an Aura Free account which will have full, real certs and try connecting to that with your react app.  
Or port 7687 is blocked.

---

<div class="post-metadata">

**Author:** ![jahidmailbox98](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jahidmailbox98/32/33604_2.png) [@jahidmailbox98](https://community.neo4j.com/u/jahidmailbox98)\
**Post date:** [August 4, 2025, 6:35am UTC](https://community.neo4j.com/t/neo4j-gcp-deployment-websocket-connection-failure-and-failed-to-establish-connection/59736/8 "2025-08-04T06:35:41Z")

</div>

We tried using let’s encrypt certificate and working as expected. Thanks @**[david\_rosenblum](https://community.neo4j.com/u/david_rosenblum)**
