Apollo router does not resolve /etc/hosts

Hi,

I’m trying to make Apollo router work on local environment. When I’m trying to request to a subgraph Apollo says that there isn’t an AAAA record for the host, but the host is defined in /etc/hosts. Is there something I need to configure in Apollo Router?:

2024-06-12T07:08:04.151902Z ERROR subgraph_request{net.peer.name=user-service,net.peer.port=8082,http.route=/graphql,http.url=http://user-service:8082/graphql,net.transport=ip_tcp,apollo.subgraph.name=user-service,graphql.operation.name=SocialLogin__user_service__0,} subgraph{apollo.subgraph.name=user-service,graphql.document=mutation SocialLogin__user_service__0($input:SocialLoginInput){socialLogin(input:$input){__typename ...on TokenResponse{token expiration refreshToken}...on OTPRequest{uuid missingOtp}}},graphql.operation.name=SocialLogin__user_service__0,subgraph.name=user-service,} fetch{apollo.subgraph.name=user-service,} execution{graphql.operation.type=mutation,} supergraph{graphql.operation.name=SocialLogin,graphql.document=mutation SocialLogin($input: SocialLoginInput) {
  socialLogin(input: $input) {
    ... on TokenResponse {
      token
      expiration
      refreshToken
    }
    ... on OTPRequest {
      uuid
      missingOtp
    }
  }
},graphql.operation.name=SocialLogin,} router{http.method=POST,http.request.method=POST,http.route=/graphql,http.flavor=HTTP/1.1,trace_id=759257028a51401e0d4fcb038cfc3359,url.path=/graphql,client.name=,client.version=,} request{http.method=POST,http.request.method=POST,http.route=/graphql,http.flavor=HTTP/1.1,}  fetch_error=SubrequestHttpError { status_code: None, service: "user-service", reason: "error trying to connect: dns error: no record found for Query { name: Name(\"user-service.\"), query_type: AAAA, query_class: IN }" }
2024-06-12T07:08:07.721917Z WARN  traces will not be sent to Apollo as this account is on a free plan
^C2024-06-12T07:08:34.513489Z INFO  shutting down
2024-06-12T07:08:34.513674Z INFO  all connections shut down
2024-06-12T07:08:34.520537Z INFO  stopped
(base) hugo@msigl65:~/projects/msc/backend/apollo-router$ curl user-service:8082/graphql -v
*   Trying 127.0.0.1:8082...
* Connected to user-service (127.0.0.1) port 8082 (#0)
> GET /graphql HTTP/1.1
> Host: user-service:8082
> User-Agent: curl/7.71.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 405 
< Vary: Origin
< Vary: Access-Control-Request-Method
< Vary: Access-Control-Request-Headers
< Allow: POST
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 0
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Content-Length: 0
< Date: Wed, 12 Jun 2024 07:10:13 GMT
< 
* Connection #0 to host user-service left intact

Thanks,
Hugo

Hey there,
Apollo router is encountering a DNS error because it can’t find an AAAA record for the host “user-service” despite it being defined in your /etc/hosts. To fix this, configure Apollo router to recognize entries from /etc/hosts for host resolution or use the IP address directly instead of the hostname. Check for configuration options or environment variables in Apollo router for custom DNS resolution settings or host configurations.

Thanks Alina for your answer. I was looking for this information but I didn’t find anythings, this is why I’m asking here. Can you point me to the correct configuration page?

To fix the DNS error in Apollo Router you can either use IP Address Directly or Configure DNS Settings :innocent:

Sorry Alina, I’m not sure if I understand correctly your answer. Are you saying that its not possible to use /etc/hosts entry to resolve hosts with apollo router?

I am not sure I have not used them.

The problem was that I’m running apollo router from Docker :man_facepalming: