```pact-broker publish ./pacts --consumer-app-vers...
# pact-js
f
Copy code
pact-broker publish ./pacts --consumer-app-version="1.0.0" --auto-detect-version-properties --broker-base-url=<http://localhost:9292>

/home/node/app/node_modules/@pact-foundation/pact-core/standalone/linux-arm64-2.0.3/pact/lib/ruby/lib/ruby/3.2.0/net/http.rb:1271:in `initialize': Failed to open TCP connection to localhost:9292 (Cannot assign requested address - connect(2) for "localhost" port 9292) (Errno::EADDRNOTAVAIL)
I am getting this error trying to publish the pact. My pact-broker is running in a docker container and my app is in another docker container. They are both in the same network. I am using a mac m1, my app is using node 20 image. Should I open an issue for this?
1
pact-broker docker compose ⬇️
Copy code
pact-broker:
    container_name: local-environment-pact-broker
    image: "pactfoundation/pact-broker:latest-multi"
    ports:
      - "9292:9292"
    depends_on:
      - postgres
    environment:
      PACT_BROKER_PORT: '9292'
      PACT_BROKER_DATABASE_URL: "<postgres://postgres:password@postgres/postgres>"
      PACT_BROKER_LOG_LEVEL: INFO
      PACT_BROKER_SQL_LOG_LEVEL: DEBUG
      # PACT_BROKER_DATABASE_CONNECT_MAX_RETRIES is only needed for docker-compose
      # because the database takes longer to start up than the puma process
      # Should not be needed in production.
      PACT_BROKER_DATABASE_CONNECT_MAX_RETRIES: "5"
      # The list of allowed base URLs (not setting this makes the app vulnerable to cache poisoning)
      # This list allows the app to be addressed from the host and from within another docker container correctly
      # Ngnix config below makes the app accessible on ports 443 and 80, while the Ruby application itself runs on port 9292
      PACT_BROKER_BASE_URL: '<https://localhost> <http://localhost> <http://localhost:9292> <http://pact-broker:9292> <https://host.docker.internal> <http://host.docker.internal> <http://host.docker.internal:9292>'
m
Are you sure that both containers are on the same network?
👍 1
i.e. from the node image, attempting to hit
localhost:9292
would only work if both containers are running the same network (usually not the case). So that could explain that problem
f
they are both on same network
m
Forgive my persistence, but can you please show how you know they are on the same network?
It’s not enough for the containers to be running on the same underlying instance (e.g. your macbook). Docker logically separates the container networks. i.e.
localhost
from the docker container running the publish is not likely to be able to access
9292
of the pact-broker docker container, unless you link them or explicitly set the network for them (which from the setup of docker compose doesn’t look to be the case)
👍 1