hydra-python-agent icon indicating copy to clipboard operation
hydra-python-agent copied to clipboard

Connection refused on localhost - only with Docker

Open gustavodemorais opened this issue 6 years ago • 10 comments

I'm submitting a

  • [x] bug report.
  • [ ] feature request.

Current Behaviour:

When trying to connect to a localhost hydrus server using docker, the agent returns Connection refused as the image:

image

However, it works for http://35.224.198.158:8080/api. At the same time, running python querying_mechanism.py directly works perfectly for both remote and local server.

Expected Behaviour:

Running via docker should enable to connect to local hydrus servers.

Do you want to work on this issue?

Yes, but appreciate any suggestions since I'm not really sure the reason for it

gustavodemorais avatar May 30 '19 12:05 gustavodemorais

The error message received seems to be somehow related to docker not being able to connect to Redis(but not sure)

gustavodemorais avatar May 30 '19 12:05 gustavodemorais

Which OS are you using?

xadahiya avatar May 30 '19 12:05 xadahiya

I'm on ubuntu 18.04

gustavodemorais avatar May 30 '19 12:05 gustavodemorais

The error message received seems to be somehow related to docker not being able to connect to Redis(but not sure)

If that was the case, Docker wouldn't have connected to http://35.224.198.158:8080/api as well. The problem seems to be of docker not being able to detect localhost. Kindly take a look here https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach

shravandoda avatar May 30 '19 13:05 shravandoda

Quick fix:

Linux: sudo ip addr show docker0

Copy the default docker bridge link that is created, by default it's http://172.17.0.1

Windows/Mac: Use http://host.docker.internal instead of http://localhost

If you use Windows/Mac and can test this solution and give a thumbs up would be helpful so I can add in the docs. Also, seems like soon host.docker.internal should work in all OS.

Follow the post mentioned by @motormouthdoda for more answers.

gustavodemorais avatar May 30 '19 15:05 gustavodemorais

@Guttz can we put this configuration bit in docker-compose or in a bash script?

Mec-iS avatar May 30 '19 16:05 Mec-iS

I tried it for a while but didn't find something for all OS. I will install a VM to test some other compatibility matters with the agent and then I come back here and take a look again into this.

gustavodemorais avatar May 30 '19 21:05 gustavodemorais

Quick fix: Linux: sudo ip addr show docker0

Copy the default docker bridge link that is created, by default it's http://172.17.0.1

Windows/Mac: Use http://host.docker.internal instead of http://localhost

If you use Windows/Mac and can test this solution and give a thumbs up would be helpful so I can add in the docs. Also, seems like soon host.docker.internal should work in all OS.

Follow the post mentioned by @motormouthdoda for more answers.

I suppose we can just add this part to a "Troubleshooting" section in the README

Mec-iS avatar Jun 03 '19 17:06 Mec-iS

Yes, at least for now, I'll add this there while we can come up with a better solution.

There's a PR on docker which would make http://host.docker.internal a universal solution but it doesn't seem like a priority right now: https://github.com/docker/libnetwork/pull/2348

gustavodemorais avatar Jun 04 '19 11:06 gustavodemorais

Hi, @Guttz I am new to the community, could you help me getting this issue resolved. Also new to open source :)

Blakelist7 avatar Mar 11 '21 18:03 Blakelist7