# How to start multiple ray instances on one machine with \`ray.init()\`?

**URL:** <https://discuss.ray.io/t/how-to-start-multiple-ray-instances-on-one-machine-with-ray-init/15175>\
**Category:** Ray Clusters\
**Created:** [July 10, 2024, 12:41pm UTC](https://discuss.ray.io/t/how-to-start-multiple-ray-instances-on-one-machine-with-ray-init/15175 "2024-07-10T12:41:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidxia](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/davidxia/32/2951_2.png) [@davidxia](https://discuss.ray.io/u/davidxia)\
**Post date:** [July 10, 2024, 12:41pm UTC](https://discuss.ray.io/t/how-to-start-multiple-ray-instances-on-one-machine-with-ray-init/15175/1 "2024-07-10T12:41:27Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- Low: It annoys or frustrates me for a moment.

## How can I start multiple ray instances on one machine with `ray.init()`?

### info

- ray 2.23.0
- Python 3.9.19
- Ubuntu 20.04 focal

### repro steps

1. In the Python REPL, start a new ray instance.

2. Calling `ray.init()` again doesn’t start a new instance (note the same `dashboard_url` in the output) even though the `ray.init()` [docs here](https://docs.ray.io/en/releases-2.23.0/ray-core/api/doc/ray.init.html) says it should.

3. Using a different `dashboard_port` also doesn’t work. Same `dashboard_url` returned.

4. Running `ray.init()` in a new, concurrent Python REPL successfully starts new Ray instance (new 8266 port), but it’s broken because it doesn’t have any “available agent.”

## Questions

1. How can I start multiple, working Ray instances in the same Python session? There’s a way [described here](https://discuss.ray.io/t/error-in-ray-job-submit-on-local-machine-if-multiple-clusters-are-running-at-the-same-time/14723/17) with the CLI command `ray start`, but what’s the SDK equivalent of these commands especially for CLI switches like `--dashboard-agent-listen-port`?
2. How can I start multiple, working Ray instances in different Python sessions?
3. Is the `ray.init()` [documentation here](https://docs.ray.io/en/releases-2.23.0/ray-core/api/doc/ray.init.html) correct? Should it mention something about different sessions as a requirement?

> 1. If the provided address is “local”, start a new local Ray instance, even if there is already an existing local Ray instance.
