Ray start --head error,Unable to connect to Redis at 127.0.0.1:6379

Can anyone help me solve this problem? Thanks

when use ray start --head

[root@ecs-0005 servers]# ray start --head
Local node IP: 192.168.0.115
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/redis/connection.py”, line 576, in connect
sock = self._connect()
File “/usr/local/lib/python3.7/site-packages/redis/connection.py”, line 634, in _connect
raise err
File “/usr/local/lib/python3.7/site-packages/redis/connection.py”, line 622, in _connect
sock.connect(socket_address)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/ray/_private/services.py”, line 648, in wait_for_redis_to_start
redis_client.client_list()
File “/usr/local/lib/python3.7/site-packages/redis/commands/core.py”, line 358, in client_list
return self.execute_command(‘CLIENT LIST’, *args)
File “/usr/local/lib/python3.7/site-packages/redis/client.py”, line 1085, in execute_command
conn = self.connection or pool.get_connection(command_name, **options)
File “/usr/local/lib/python3.7/site-packages/redis/connection.py”, line 1182, in get_connection
connection.connect()
File “/usr/local/lib/python3.7/site-packages/redis/connection.py”, line 580, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/local/bin/ray”, line 8, in
sys.exit(main())
File “/usr/local/lib/python3.7/site-packages/ray/scripts/scripts.py”, line 1969, in main
return cli()
File “/usr/local/lib/python3.7/site-packages/click/core.py”, line 1128, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/click/core.py”, line 1053, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.7/site-packages/click/core.py”, line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.7/site-packages/click/core.py”, line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.7/site-packages/click/core.py”, line 754, in invoke
return __callback(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/ray/scripts/scripts.py”, line 626, in start
ray_params, head=True, shutdown_at_exit=block, spawn_reaper=block)
File “/usr/local/lib/python3.7/site-packages/ray/node.py”, line 248, in init
self.start_head_processes()
File “/usr/local/lib/python3.7/site-packages/ray/node.py”, line 900, in start_head_processes
self.start_redis()
File “/usr/local/lib/python3.7/site-packages/ray/node.py”, line 720, in start_redis
port_denylist=self._ray_params.reserved_ports)
File “/usr/local/lib/python3.7/site-packages/ray/_private/services.py”, line 875, in start_redis
listen_to_localhost_only=(node_ip_address == “127.0.0.1”))
File “/usr/local/lib/python3.7/site-packages/ray/_private/services.py”, line 1030, in _start_redis_instance
wait_for_redis_to_start(“127.0.0.1”, port, password=password)
File “/usr/local/lib/python3.7/site-packages/ray/_private/services.py”, line 670, in wait_for_redis_to_start
" attempts to ping the Redis server.") from connEx
RuntimeError: Unable to connect to Redis at 127.0.0.1:6379 after 16 retries. Check that 127.0.0.1:6379 is reachable from this machine. If it is not, your firewall may be blocking this port. If the problem is a flaky connection, try setting the environment variable RAY_START_REDIS_WAIT_RETRIES to increase the number of attempts to ping the Redis server.

It seems you didn’t perform ray.stop from the earlier attempts. I suggest, run netstat or ps -ef on this node and make sure no Redis process not running. If it is running then kill it and start ray again.

I believe you starting ray head with embedded Redis server and not remote Redis server.

Thank you for your answers, but I don’t seem to have started ray successfully. I feel that redis did not start successfully when ray was started, so redis could not be connected.

[root@ecs-0005 ~]# ps -aux|grep redis
root 188328 0.0 0.0 214016 1536 pts/0 S+ 11:51 0:00 grep redis

我的环境是python3.7
ray2.0
redis 4.0

Can you first try start ray from python interactive mode and see if it works

# python 
import ray
ray.init()

After that, you can start ray head (make sure to replace IP address if it is not the same)

ray start --head --node-ip-address=192.168.0.115 --address=192.168.0.115

I suggest you to try ray official release 1.8.0 instead of ray-2-dev daily build.