Docker-compose: Failed to establish a new connection: [Errno 111] Connection refused'

The post is not formatted properly, which makes it hard to read. Please format it according this post: How to format your forum posts

Why would you expect the test_ui service to reach the application of the selenoid service using localhost?

Localhost of a container is not the same localhost of the host or any other container.

Please do not use network_mode: bridge, as it will put all containers into the default docker bridge network (not to confuse with a default network docker compose creates for this project). The default docker bridge network does not support dns-based service discovery. Remove this setting for all declared service and let the containers use the default network docker compose creates for you, as it provides service discovery.

Then use the service name of the target service to communicate with it:
Instead of HTTPConnectionPool(host=‘localhost’, port=4444), it must be HTTPConnectionPool(host=‘selenoid’, port=4444).