Search code examples
dockergoodoo

Docker Get http://localhost:8091/api/order: dial tcp 127.0.0.1:8091: connect: connection refused


i have 2 containers in Docker:

  1. golang service
  2. odoo service

the golang service will hit api in odoo service

i've tried it without 2 docker containers it works fine but when i make my golang service into docker container i got this error

im aware of this post Getting error "Get http://localhost:9443/metrics: dial tcp 127.0.0.1:9443: connect: connection refused"

this is how i define my odoo url in golang

var OdoobaseURL = "http://localhost:8091/api/order"

but how can i solve it in golang? thanks


Solution

  • When running your application with Docker Compose you'll have to address the target container via it's service name. When running the Go service separately you'll have expose the odoo service port and then you can use localhost to connect.