Errno: Cannot connect to host localhost
sonnenschein123 opened this issue · 17 comments
Hello,
I have set up a local OSF instance. When I try to connect with waterbutler I always get this error:
Traceback (most recent call last): File "/home/web/.virtualenvs/waterbutler/lib/python3.5/site-packages/tornado/web.py", line 1445, in _execute result = yield result File "/home/web/.virtualenvs/waterbutler/lib/python3.5/site-packages/tornado/gen.py", line 1008, in run value = future.result() File "/home/web/.virtualenvs/waterbutler/lib/python3.5/site-packages/tornado/concurrent.py", line 232, in result raise_exc_info(self._exc_info) File "<string>", line 3, in raise_exc_info File "/home/web/.virtualenvs/waterbutler/lib/python3.5/site-packages/tornado/gen.py", line 1014, in run yielded = self.gen.throw(*exc_info) File "<string>", line 6, in _wrap_awaitable File "/home/web/Workspace/waterbutler/waterbutler/server/api/v1/provider/__init__.py", line 94, in get return (await self.get_folder()) File "/home/web/Workspace/waterbutler/waterbutler/server/api/v1/provider/metadata.py", line 40, in get_folder data = await self.provider.metadata(self.path, version=version, revision=version) File "/home/web/Workspace/waterbutler/waterbutler/providers/osfstorage/provider.py", line 431, in metadata return await self._children_metadata(path) File "/home/web/Workspace/waterbutler/waterbutler/providers/osfstorage/provider.py", line 478, in _children_metadata expects=(200, ) File "/home/web/Workspace/waterbutler/waterbutler/core/utils.py", line 156, in __aenter__ self.request = await self.request_coro File "/home/web/Workspace/waterbutler/waterbutler/providers/osfstorage/provider.py", line 232, in make_signed_request return await self.make_request(method, url, data=data, params=params, **kwargs) File "/home/web/Workspace/waterbutler/waterbutler/core/provider.py", line 45, in wrapped return (await func(*args, **kwargs)) File "/home/web/Workspace/waterbutler/waterbutler/core/provider.py", line 175, in make_request response = await aiohttp.request(method, url, *args, **kwargs) File "/home/web/.virtualenvs/waterbutler/lib/python3.5/site-packages/aiohttp/client.py", line 446, in __await__ resp = yield from self._coro File "/home/web/.virtualenvs/waterbutler/lib/python3.5/site-packages/aiohttp/client.py", line 173, in _request conn = yield from self._connector.connect(req) File "/home/web/.virtualenvs/waterbutler/lib/python3.5/site-packages/aiohttp/connector.py", line 299, in connect .format(key, exc.strerror)) from exc aiohttp.errors.ClientOSError: [Errno None] Cannot connect to host localhost:5000 ssl:True [Can not connect to localhost:5000 [None]]
I don't know why the waterbulter want to connect with localhost.
Has anyone an idea what the problem is?
Hey @sonnenschein123,
Are you running this as part of the dockerized OSF or as a standalone service?
Hey @felliott,
I use OSF and waterbutler as a standalone service.
Hey @felliott,
I use OSF and waterbutler as a standalone service.
Hello @sonnenschein123 , are you using docker-compose to start up osf.io and waterbutler? In answer to "why the waterbulter want to connect with localhost", waterbutler is trying to communicate with osf.io at localhost:5000 . That may or may not be correct depending on how you have installed/configured osf.io and waterbutler.
Hey @TomBaxter, thanks for your answer.
Waterbutler and OSF are running as a local standalone service without docker. In OSF I set WATERBUTLER_URL, WATERBUTLER_ADDRS
and WATERBUTLER_INTERNAL_URL
and on waterbutler I set the API_URL
and in ~/.cos/waterbutler-test.json I set ALLOWED_PROVIDER_DOMAINS
and the API_URL
again. Waterbutler still try to connect to localhost:5000 but it should not.
Ok, understood. And I assume then that you are not running your local osf.io instance at localhost:5000. So, when you say you have set API_URL, I assume that you mean that you have created and edited the file ~/.cos/waterbutler.json or ~/.cos/waterbutler-test.json . And in that file ...
{
...
{ "OSF_AUTH_CONFIG": {
"API_URL": "http://<YOUR_HOST>:<YOUR_PORT>/api/v1/files/auth/"
}
...
}
... exists. Is that correct? And you are starting the services as the user referred to by "~" in "~/.cos/" ?
If all that is true and still does not seem to have an effect, try changing the default for the API_URL config in the code to your osf.io instance, just to make sure API_URL is really our issue. that code is found in ....
waterbutler/auth/osf/settings.py
currently at line 21.
If changing that has no effect, then API_URL is not the issue.
Not to beat a dead horse, but I want to make sure I understand. When you say that Waterbutler should not be trying to connect to localhost:5000, that is beacuse you are running osf.io at something other then the default host and port. Is that correct?
Thanks, Tom
Its all correct. I have created and edited the file ~/.cos/waterbutler.json. And to be safe I set API_URL in waterbutler/auth/osf/settings.py. But it has no effect.
I just noticed this bit: Cannot connect to host localhost:5000 ssl:True
. Maybe it's trying to connect to https://localhost:5000/? If that's the case then maybe SECURE_MODE
is being turned on either on the OSF side or WB side.
hey @felliott, the SECURE_MODE
is turned on, because I want that the parts are communicate via SSL this each other.
Have you already set up ssl in front of the OSF? Can you connect to https://localhost:5000 in your browser?
I have set up OSF and I can connect https://SERVERNAME:5000 with my browser.
The osfstorage provider gets the url to the OSF from the OSF itself, in the provider settings. baseUrl
is constructed in the osfstorage addon in the OSF. That line is telling it to build the internal url (needed when running via Docker-compose), so perhaps the internal url is still being set to https://localhost:5000/
instead of https://SERVERNAME:5000/
somewhere.
api_url_for
uses website.settings.INTERNAL_DOMAIN
to build internal urls. Can you confirm that's being set to https://SERVERNAME:5000/
?
Thanks @felliott, this was the problem.
thanks a lot.
Hello again,
I have the same problem in communication between waterbutler and mfr. mfr always throws the message: aiohttp.errors.ClientOSError: [Errno None] Cannot connect to host localhost:7777 ssl:False [Can not connect to localhost:7777
Is there a similar value in waterbutler?
Hey @sonnenschein123!
That value is not set directly in WB, but in the osf docker-compose setup. See: https://github.com/CenterForOpenScience/osf.io/blob/develop/.docker-compose.env#L12 Is that set correctly?
What kind of file are you trying to render? We do have some cases that aren't working for local dev b/c MFR needs to better distinguish external and internal urls.
Cheers,
@felliott
Hey @felliott,
I use OSF without Docker, but I set the value in the local.py
Thanks a lot again.