# Could not connect to socket - Kubernetes Ray

**URL:** <https://discuss.ray.io/t/could-not-connect-to-socket-kubernetes-ray/11201>\
**Category:** Kubernetes\
**Created:** [June 30, 2023, 12:39am UTC](https://discuss.ray.io/t/could-not-connect-to-socket-kubernetes-ray/11201 "2023-06-30T00:39:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![worldofsoup36](https://avatars.discourse-cdn.com/v4/letter/w/5e9695/32.png) [@worldofsoup36](https://discuss.ray.io/u/worldofsoup36)\
**Post date:** [June 30, 2023, 12:39am UTC](https://discuss.ray.io/t/could-not-connect-to-socket-kubernetes-ray/11201/1 "2023-06-30T00:39:30Z")

</div>

Hi, we have a Kubernedes cluster. Our YAML file specifies a “kind: Deployment” which is a docker container with our flask app and a “kind: RayCluster” which is a Ray cluster with a head and two workers. We are trying to ray.init from our flask app to the Ray cluster. I have been able to connect to the Ray cluster by running “kubectl exec -it [FLASK POD NAME] – /bin/bash”, then “python”, then “import ray”, “ray.init(address=‘[RAY IP OF RAY HEAD]:6379’, \_node\_ip\_address=‘[RAY IP OF RAY HEAD]’)” (I have tried connecting through a service or without \_node\_ip\_address and neither works, but I just want to connect right now in any way that works). However, from my actually flask app inside my Docker container, with the same ray.init command I get this error:  
(base) kubectl logs [POD NAME]

- Tip: There are .env or .flaskenv files present. Do “pip install python-dotenv” to use them.
- Environment: production  
WARNING: This is a development server. Do not use it in a production deployment.  
Use a production WSGI server instead.
- Debug mode: off  
2023-06-28 02:54:51,158 INFO worker.py:1452 – Connecting to existing Ray cluster at address: [IP]…  
2023-06-28 02:54:51,170 INFO worker.py:1627 – Connected to Ray cluster. View the dashboard at [IP]  
[2023-06-28 02:55:01,218 C 7 7] raylet\_client.cc:60: Could not connect to socket /tmp/ray/session\_2023-06-27\_06-11-52\_301872\_8/sockets/raylet  
\*\*\* StackTrace Information \*\*\*  
/usr/local/lib/python3.8/site-packages/ray/\_raylet.so(+0xdc551a) [0x7f150e97051a] ray::operator\<\<()  
/usr/local/lib/python3.8/site-packages/ray/\_raylet.so(+0xdc7002) [0x7f150e972002] ray::SpdLogMessage::Flush()  
/usr/local/lib/python3.8/site-packages/ray/\_raylet.so(\_ZN3ray6RayLogD1Ev+0x37) [0x7f150e972317] ray::RayLog::~RayLog() // more stack trace lines.  
Any ideas? I am using Ray 2.5.1, Python 3.8.13.

---

<div class="post-metadata">

**Author:** ![Morphlng](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/morphlng/32/5785_2.png) [@Morphlng](https://discuss.ray.io/u/Morphlng)\
**Post date:** [August 28, 2024, 8:37am UTC](https://discuss.ray.io/t/could-not-connect-to-socket-kubernetes-ray/11201/2 "2024-08-28T08:37:39Z")

</div>

I’m facing the same problem when using docker to setup Ray cluster. Have you solved the problem?
