DNS service consul with nomad

hi
I am trying to access the container with service consul in nomad


dig @10.11.205.89 -p 8600 postgres.service.consul

; <<>> DiG 9.11.36-RedHat-9.11.36-5.el8 <<>> @10.11.205.89 -p 8600 postgres.service.consul
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55304
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;postgres.service.consul.       IN      A

;; ANSWER SECTION:
postgres.service.consul. 0      IN      A       10.11.205.89

;; Query time: 1 msec
;; SERVER: 10.11.205.89#8600(10.11.205.89)
;; WHEN: Mon Dec 12 12:47:52 IST 2022
;; MSG SIZE  rcvd: 68

There is access from the vm
but not from another container

postgresql+psycopg2://airflow:airflow@postgres.service.consul:5432/airflow

(psycopg2.OperationalError) could not translate host name "postgres.service.consul" to address: Name or service not known

I would be happy for help and an explanation. I must be missing something in the definition

Hi @yaelkadosh,

You will need to configure your Nomad hosts to forward DNS requests to Consul so that your application can resolve your service name. See the following tutorial for information on how to do this using various DNS resolvers.