Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: backend-core | httpx.ConnectError: [Errno -2] Name or service not known #2008

Closed
oanhcuongdo opened this issue Jan 11, 2024 · 8 comments
Labels
area: backend Related to backend functionality or under the /backend directory bug Something isn't working Stale type: dependencies

Comments

@oanhcuongdo
Copy link

What happened?

I get this error when access brain/ chat please help: backend-core | httpx.ConnectError: [Errno -2] Name or service not known

Relevant log output

backend-core  |     await self.app(scope, receive, send)
backend-core  |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
backend-core  |     await route.handle(scope, receive, send)
backend-core  |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
backend-core  |     await self.app(scope, receive, send)
backend-core  |   File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
backend-core  |     response = await func(request)
backend-core  |                ^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 237, in app
backend-core  |     raw_response = await run_endpoint_function(
backend-core  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
backend-core  |     return await dependant.call(**values)
backend-core  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/code/modules/onboarding/controller/onboarding_routes.py", line 28, in get_user_onboarding_handler
backend-core  |     return onboardingService.get_user_onboarding(current_user.id)
backend-core  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/code/modules/onboarding/service/onboarding_service.py", line 30, in get_user_onboarding
backend-core  |     return self.repository.get_user_onboarding(user_id)
backend-core  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/code/modules/onboarding/repository/onboardings.py", line 29, in get_user_onboarding
backend-core  |     .execute()
backend-core  |      ^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/postgrest/_sync/request_builder.py", line 57, in execute
backend-core  |     r = self.session.request(
backend-core  |         ^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 814, in request
backend-core  |     return self.send(request, auth=auth, follow_redirects=follow_redirects)
backend-core  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 901, in send
backend-core  |     response = self._send_handling_auth(
backend-core  |                ^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 929, in _send_handling_auth
backend-core  |     response = self._send_handling_redirects(
backend-core  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 966, in _send_handling_redirects
backend-core  |     response = self._send_single_request(request)
backend-core  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1002, in _send_single_request
backend-core  |     response = transport.handle_request(request)
backend-core  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-core  |   File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 217, in handle_request
backend-core  |     with map_httpcore_exceptions():
backend-core  |   File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
backend-core  |     self.gen.throw(typ, value, traceback)
backend-core  |   File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
backend-core  |     raise mapped_exc(message) from exc
backend-core  | httpx.ConnectError: [Errno -2] Name or service not known

Twitter / LinkedIn details

No response

@oanhcuongdo oanhcuongdo added the bug Something isn't working label Jan 11, 2024
Copy link

dosubot bot commented Jan 11, 2024

🤖

Hello @oanhcuongdo! 👋

I'm Dosu, a friendly bot here to help you out with your issues, answer questions, and guide you through the contribution process while the human maintainers are busy. I see you've bumped into a bug, and I want you to know that I'm currently reviewing your issue. Expect a detailed response shortly! 💻🔍

@oanhcuongdo oanhcuongdo changed the title [Bug]: [Bug]: backend-core | httpx.ConnectError: [Errno -2] Name or service not known Jan 11, 2024
@oanhcuongdo
Copy link
Author

backend-core | httpx.ConnectError: [Errno -2] Name or service not known when i access : localhost:3000/chat

@dosubot dosubot bot added area: backend Related to backend functionality or under the /backend directory type: dependencies labels Jan 11, 2024
@jimmidier
Copy link

jimmidier commented Jan 16, 2024

It's likely due to docker engine on Linux not adding host.docker.internal to the container hosts, which leads to a DNS failure.
Try adding the host by yourself,

# In docker-compose.yml

backend-core:
  ...
  extra_hosts:
      - "host.docker.internal:host-gateway"

@dastaj
Copy link

dastaj commented Jan 20, 2024

@jimmidier I also had this problem and your solution helped. However, now I have other errors:
image
Maybe you, or anyone, had solution for this issue (postgres exception)?

Copy link

dosubot bot commented Jan 20, 2024

🤖

The error "httpx.ConnectError: [Errno -2] Name or service not known" typically occurs when the URL you're trying to connect to is not valid or cannot be resolved. In your case, it seems like the error might be coming from the quivr_url variable.

The quivr_url is constructed from environment variables QUIVR_URL, QUIVR_CHAT_ID, and QUIVR_BRAIN_ID. If any of these variables are not set correctly in your environment or .env file, it could result in an invalid URL, causing the error you're seeing.

Here are a few things you can check:

  1. Ensure that the QUIVR_URL, QUIVR_CHAT_ID, and QUIVR_BRAIN_ID environment variables are set correctly in your .env file or environment.

  2. Check if the quivr_url is a valid URL. You can print it out before the requests.post call in the handle_message function to see what it is.

print(quivr_url)
response = requests.post(
    quivr_url, headers=headers, json={"question": user_message}
)
  1. If you're running this on your local machine, make sure your machine can resolve and reach the QUIVR_URL. You can test this by trying to access the URL in a web browser or using a tool like curl or ping from the command line.

If all these are set correctly and you're still facing the issue, it might be a problem with your network or DNS settings. You can refer to the connectors/telegram_bot/main.py for more details.

If you're still having trouble, could you provide more information about your setup? Specifically, the values of your QUIVR_URL, QUIVR_CHAT_ID, and QUIVR_BRAIN_ID (please make sure to not share any sensitive information or tokens). This will help in diagnosing the issue further.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@jimmidier
Copy link

@jimmidier I also had this problem and your solution helped. However, now I have other errors: image Maybe you, or anyone, had solution for this issue (postgres exception)?

@dastaj Seems like a database schema issue but I don't recognize this one so not sure. It may help if you could provide full stack trace and error messages for others to reference

@gustavklopp
Copy link

gustavklopp commented Feb 2, 2024

It's likely due to docker engine on Linux not adding host.docker.internal to the container hosts, which leads to a DNS failure. Try adding the host by yourself,

# In docker-compose.yml

backend-core:
  ...
  extra_hosts:
      - "host.docker.internal:host-gateway"

I'm not sure how I have to modify this file:
/home/gustabklopp/huginn2019/docker/single-process/docker-compose.yml
Like this? (it gives the same error)

version: '2'

services:
  mysqldata:
    image: mysql:5.7
    command: /bin/true

  mysql:
    image: mysql:5.7
    restart: always
    env_file:
      - ../mysql.env
    volumes_from:
      - mysqldata

  web:
    image: huginn/huginn-single-process
    restart: always
    ports:
      - "3000:3000"
    env_file:
      - ../mysql.env
      - ../secrets.env
    depends_on:
      - mysql

  threaded:
    image: huginn/huginn-single-process
    command: /scripts/init bin/threaded.rb
    restart: always
    env_file:
      - ../mysql.env
      - ../secrets.env
    depends_on:
      - mysql
      - web

  backend-core:
    extra_hosts:
      - "host.docker.internal:host-gateway"

Thanks!

Copy link
Contributor

github-actions bot commented May 2, 2024

Thanks for your contributions, we'll be closing this issue as it has gone stale. Feel free to reopen if you'd like to continue the discussion.

@github-actions github-actions bot added the Stale label May 2, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: backend Related to backend functionality or under the /backend directory bug Something isn't working Stale type: dependencies
Projects
None yet
Development

No branches or pull requests

4 participants