# How to change default address for ray.init()

**URL:** <https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464>\
**Category:** Ray Core\
**Created:** [March 18, 2022, 6:32pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464 "2022-03-18T18:32:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ray\_rlw](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ray\_rlw](https://discuss.ray.io/u/Ray_rlw)\
**Post date:** [March 18, 2022, 6:32pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/1 "2022-03-18T18:32:47Z")

</div>

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

- High: It blocks me to complete my task.

Need to change the default address. Integrating with another application as a plugin has its own scheduler using rays default address. This causes ray workers/actors to be canceled/killed before processing is complete.

---

<div class="post-metadata">

**Author:** ![Stephanie\_Wang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/stephanie_wang/32/18_2.png) [@Stephanie\_Wang](https://discuss.ray.io/u/Stephanie_Wang)\
**Post date:** [March 18, 2022, 6:47pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/2 "2022-03-18T18:47:08Z")

</div>

You can set the OS environment variable RAY\_ADDRESS to override the `ray.init()` address.

---

<div class="post-metadata">

**Author:** ![Ray\_rlw](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ray\_rlw](https://discuss.ray.io/u/Ray_rlw)\
**Post date:** [March 18, 2022, 8:57pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/3 "2022-03-18T20:57:40Z")

</div>

Thanks I will give that a try.

---

<div class="post-metadata">

**Author:** ![Ray\_rlw](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ray\_rlw](https://discuss.ray.io/u/Ray_rlw)\
**Post date:** [March 21, 2022, 3:51pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/4 "2022-03-21T15:51:41Z")

</div>

Alas it does not seem to work.

Is it just the IP address or is IP Address:PORT that should be expressed. If port should be added what is the default?

```auto
  File "D:\apps\vec\formatters\ATAKRadar.py", line 20, os.environ["RAY_ADDRESS"] = "127.0.1.1"
  File "D:\apps\vec\ingestors\converter_ATAKRadar.py", line 33, in __init__
    ray.init(local_mode=False, ignore_reinit_error=True, _temp_dir=ray_session_path)
  File "d:\venv\lib\site-packages\ray\_private\client_mode_hook.py", line 105, in wrapper
    return func(*args, **kwargs)
  File "d:\venv\lib\site-packages\ray\worker.py", line 975, in init
    connect_only=True)
  File "d:\venv\lib\site-packages\ray\node.py", line 166, in __init__
    self.validate_ip_port(self.address)
  File "d:\venv\lib\site-packages\ray\node.py", line 302, in validate_ip_port
    _ = int(port)
ValueError: invalid literal for int() with base 10: '127.0.1.1'

```

Thanks

---

<div class="post-metadata">

**Author:** ![Ray\_rlw](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ray\_rlw](https://discuss.ray.io/u/Ray_rlw)\
**Post date:** [March 21, 2022, 4:28pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/5 "2022-03-21T16:28:42Z")

</div>

I added a port number, so that exception above goes away. Now I get warning and the code will not function.

```auto
2022-03-21 12:18:51,604 WARNING node.py:1466 -- Unable to connect to GCS at 127.0.1.1:14000. Check that (1) Ray GCS with matching version started successfully at the specified address, and (2) there is no firewall setting preventing access.

```

At this point I do not see a way to use just **RAY\_ADDRESS** to change the default address it is using. When I allow both the DASK scheduler to use the same address my code does work however there is a performance penalty.

---

<div class="post-metadata">

**Author:** ![Stephanie\_Wang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/stephanie_wang/32/18_2.png) [@Stephanie\_Wang](https://discuss.ray.io/u/Stephanie_Wang)\
**Post date:** [March 22, 2022, 6:11pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/6 "2022-03-22T18:11:53Z")

</div>

Hmm I think I misunderstood your original question. `RAY_ADDRESS` is used to specify the address that the Ray driver/client should connect to, but it assumes that there is already a Ray instance running there.

Try using `ray start --head --port <custom port or 0 to choose a random one>` to start a Ray instance, then you can connect to it with `ray.init(address="auto")`.

---

<div class="post-metadata">

**Author:** ![Ray\_rlw](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ray\_rlw](https://discuss.ray.io/u/Ray_rlw)\
**Post date:** [March 22, 2022, 7:11pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/7 "2022-03-22T19:11:11Z")

</div>

Currently the ray app is embedded as a package and not separate instance that is running.

---

<div class="post-metadata">

**Author:** ![Stephanie\_Wang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/stephanie_wang/32/18_2.png) [@Stephanie\_Wang](https://discuss.ray.io/u/Stephanie_Wang)\
**Post date:** [March 22, 2022, 8:03pm UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/8 "2022-03-22T20:03:06Z")

</div>

Hmm not sure I understand the issue you’re running into. Are you just using `ray.init()` to start Ray? This should choose a random port, so I’m not sure how you’re getting a port conflict. What version of Ray are you using?

---

<div class="post-metadata">

**Author:** ![Ray\_rlw](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ray\_rlw](https://discuss.ray.io/u/Ray_rlw)\
**Post date:** [March 23, 2022, 12:10am UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/9 "2022-03-23T00:10:17Z")

</div>

Running version 1.11.0 and yes running ray.init() on initialization of the Class instance that other app invokes.

---

<div class="post-metadata">

**Author:** ![Ray\_rlw](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Ray\_rlw](https://discuss.ray.io/u/Ray_rlw)\
**Post date:** [March 23, 2022, 12:12am UTC](https://discuss.ray.io/t/how-to-change-default-address-for-ray-init/5464/10 "2022-03-23T00:12:59Z")

</div>

Just need ability to have it use a different IP address than 127.0.0.1 when you run with ray.init().
