title: Unable to join peer0.org2 to channel - endorser client failed to connect to peer0.org2.example.com: connection refused
body: <p>I am trying to build a network with 2 Orgs with 1 peer each and try to join them to a common channel. All cryptogen artifacts are generated as expected. Please find the yaml files below,</p>
  
  <p><strong>crypto-config.yaml</strong>   </p>
  
  <pre><code>OrdererOrgs:
    - Name: "Orderer"
      Domain: "example.com"
      Specs:
        - Hostname: "orderer"
  PeerOrgs:
    - Name: "Org1"
      Domain: "org1.example.com"
      Template:
        Count: 1
      Users:
        Count: 1
    - Name: "org2"
      Domain: "org2.example.com"
      Template:
        Count: 1
      Users:
        Count: 1
  </code></pre>
  
  <p><strong>configtx.yaml</strong></p>
  
  <pre><code>Organizations:
    - Name: "OrdererOrg"
      ID: "OrdererMSP"
      MSPDir: "crypto-config/ordererOrganizations/example.com/msp"
    - Name: "Org1MSP"
      ID: "Org1MSP"
      MSPDir: "crypto-config/peerOrganizations/org1.example.com/msp"
      AnchorPeers:
        - Host: "peer0.org1.example.com"
          Port: 7051
    - Name: "org2MSP"
      ID: "org2MSP"
      MSPDir: "crypto-config/peerOrganizations/org2.example.com/msp"
      AnchorPeers:
        - Host: "peer0.org2.example.com"
          Port: 10201
  Application:
    Organizations: null
  Orderer:
    OrdererType: "solo"
    Addresses:
      - "orderer.example.com:7050"
    BatchTimeout: "2s"
    BatchSize:
      MaxMessageCount: 10
      AbsoluteMaxBytes: "99 MB"
      PreferredMaxBytes: "512 KB"
    Kafka:
      Brokers:
        - "127.0.0.1:9092"
    Organizations: null
  Profiles:
    OneOrgOrdererGenesis:
      Orderer:
        OrdererType: "solo"
        Addresses:
          - "orderer.example.com:7050"
        BatchTimeout: "2s"
        BatchSize:
          MaxMessageCount: 10
          AbsoluteMaxBytes: "99 MB"
          PreferredMaxBytes: "512 KB"
        Kafka:
          Brokers:
            - "127.0.0.1:9092"
        Organizations:
          - Name: "OrdererOrg"
            ID: "OrdererMSP"
            MSPDir: "crypto-config/ordererOrganizations/example.com/msp"
      Consortiums:
        SampleConsortium:
          Organizations:
            - Name: "Org1MSP"
              ID: "Org1MSP"
              MSPDir: "crypto-config/peerOrganizations/org1.example.com/msp"
              AnchorPeers:
                - Host: "peer0.org1.example.com"
                  Port: 7051
            - Name: "org2MSP"
              ID: "org2MSP"
              MSPDir: "crypto-config/peerOrganizations/org2.example.com/msp"
              AnchorPeers:
                - Host: "peer0.org2.example.com"
                  Port: 10201
    OneOrgChannel:
      Consortium: "SampleConsortium"
      Application:
        Organizations:
          - Name: "Org1MSP"
            ID: "Org1MSP"
            MSPDir: "crypto-config/peerOrganizations/org1.example.com/msp"
            AnchorPeers:
              - Host: "peer0.org1.example.com"
                Port: 7051
          - Name: "org2MSP"
            ID: "org2MSP"
            MSPDir: "crypto-config/peerOrganizations/org2.example.com/msp"
            AnchorPeers:
              - Host: "peer0.org2.example.com"
                Port: 10201
  </code></pre>
  
  <p><strong>docker-compose.yaml</strong></p>
  
  <pre><code>version: "2"
  networks:
    basic: null
  services:
    ca.org1.example.com:
      image: "hyperledger/fabric-ca"
      environment:
        - "FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server"
        - "FABRIC_CA_SERVER_CA_NAME=ca-org1"
        - "FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem"
        - "FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/692b679f21458a2283135a063617ebbcca9537e6e025754c34fd573b1bc07ce3_sk"
      ports:
        - "7054:7054"
      command: "sh -c 'fabric-ca-server start -b admin:adminpw'"
      volumes:
        - "./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config"
      container_name: "ca.org1.example.com"
      networks:
        - "basic"
    ca.org2.example.com:
      image: "hyperledger/fabric-ca"
      environment:
        - "FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server"
        - "FABRIC_CA_SERVER_CA_NAME=ca-org2"
        - "FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem"
        - "FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/f19ec77442abb428ab593933bca9e4c61b86f460d40c342ecb74540068190318_sk"
      ports:
        - "8054:8054"
      command: "sh -c 'fabric-ca-server start -b admin:adminpw'"
      volumes:
        - "./crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config"
      container_name: "ca.org2.example.com"
      networks:
        - "basic"
    orderer.example.com:
      container_name: "orderer.example.com"
      image: "hyperledger/fabric-orderer"
      environment:
        - "FABRIC_LOGGING_SPEC=info"
        - "ORDERER_GENERAL_LISTENADDRESS=0.0.0.0"
        - "ORDERER_GENERAL_GENESISMETHOD=file"
        - "ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block"
        - "ORDERER_GENERAL_LOCALMSPID=OrdererMSP"
        - "ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp"
      working_dir: "/opt/gopath/src/github.com/hyperledger/fabric/orderer"
      command: "orderer"
      ports:
        - "7050:7050"
      volumes:
        - "./config/:/etc/hyperledger/configtx"
        - "./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/:/etc/hyperledger/msp/orderer"
        - "./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/msp/peerOrg1"
        - "./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/:/etc/hyperledger/msp/peerOrg2"
      networks:
        - "basic"
    peer0.org1.example.com:
      container_name: "peer0.org1.example.com"
      image: "hyperledger/fabric-peer"
      environment:
        - "CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock"
        - "CORE_PEER_ID=peer0.org1.example.com"
        - "FABRIC_LOGGING_SPEC=info"
        - "CORE_CHAINCODE_LOGGING_LEVEL=info"
        - "CORE_PEER_LOCALMSPID=Org1MSP"
        - "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/"
        - "CORE_PEER_ADDRESS=peer0.org1.example.com:7051"
        - "CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic"
        - "CORE_LEDGER_STATE_STATEDATABASE=CouchDB"
        - "CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984"
        - "CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME="
        - "CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD="
      working_dir: "/opt/gopath/src/github.com/hyperledger/fabric"
      command: "peer node start"
      ports:
        - "7051:7051"
      volumes:
        - "/var/run/:/host/var/run/"
        - "./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/msp/peer"
        - "./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users"
        - "./config:/etc/hyperledger/configtx"
      depends_on:
        - "orderer.example.com"
        - "couchdb"
      networks:
        - "basic"
    peer0.org2.example.com:
      container_name: "peer0.org2.example.com"
      image: "hyperledger/fabric-peer"
      environment:
        - "CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock"
        - "CORE_PEER_ID=peer0.org2.example.com"
        - "FABRIC_LOGGING_SPEC=info"
        - "CORE_CHAINCODE_LOGGING_LEVEL=info"
        - "CORE_PEER_LOCALMSPID=org2MSP"
        - "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/"
        - "CORE_PEER_ADDRESS=peer0.org2.example.com:10201"
        - "CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic"
        - "CORE_LEDGER_STATE_STATEDATABASE=CouchDB"
        - "CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984"
        - "CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME="
        - "CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD="
      working_dir: "/opt/gopath/src/github.com/hyperledger/fabric"
      command: "peer node start"
      ports:
        - "10201:10201"
      volumes:
        - "/var/run/:/host/var/run/"
        - "./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/msp/peer"
        - "./crypto-config/peerOrganizations/org2.example.com/users:/etc/hyperledger/msp/users"
        - "./config:/etc/hyperledger/configtx"
      depends_on:
        - "orderer.example.com"
        - "couchdb"
      networks:
        - "basic"
    couchdb:
      container_name: "couchdb"
      image: "hyperledger/fabric-couchdb"
      environment:
        - "COUCHDB_USER="
        - "COUCHDB_PASSWORD="
      ports:
        - "5984:5984"
      networks:
        - "basic"
    cli:
      container_name: "cli"
      image: "hyperledger/fabric-tools"
      tty: true
      environment:
        - "GOPATH=/opt/gopath"
        - "CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock"
        - "FABRIC_LOGGING_SPEC=info"
        - "CORE_PEER_ID=cli"
        - "CORE_PEER_ADDRESS=peer0.org1.example.com:7051"
        - "CORE_PEER_LOCALMSPID=Org1MSP"
        - "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp"
        - "CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
        - "CORE_CHAINCODE_KEEPALIVE=10"
      working_dir: "/opt/gopath/src/github.com/hyperledger/fabric/peer"
      command: "/bin/bash"
      volumes:
        - "/var/run/:/host/var/run/"
        - "./../chaincode/:/opt/gopath/src/github.com/"
        - "./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/"
        - "./config:/opt/gopath/src/github.com/hyperledger/fabric/peer/config/"
      depends_on:
        - "orderer.example.com"
        - "peer0.org1.example.com"
        - "peer0.org2.example.com"
      networks:
        - "basic"
  </code></pre>
  
  <p>All docker containers are created successfully,</p>
  
  <pre><code>CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                            NAMES
  614685a858c0        hyperledger/fabric-tools     "/bin/bash"              18 hours ago        Up 18 hours                                                          cli
  cead74ff3acf        hyperledger/fabric-peer      "peer node start"        18 hours ago        Up 18 hours         0.0.0.0:7051-&gt;7051/tcp, 0.0.0.0:7053-&gt;7053/tcp   peer0.org1.example.com
  abd07c877081        hyperledger/fabric-peer      "peer node start"        18 hours ago        Up 18 hours         0.0.0.0:10201-&gt;10201/tcp                         peer0.org2.example.com
  70ac639b1b7a        hyperledger/fabric-couchdb   "tini -- /docker-ent…"   18 hours ago        Up 18 hours         4369/tcp, 9100/tcp, 0.0.0.0:5984-&gt;5984/tcp       couchdb
  e8d04f5cac45        hyperledger/fabric-orderer   "orderer"                18 hours ago        Up 18 hours         0.0.0.0:7050-&gt;7050/tcp                           orderer.example.com
  3fafc99fe92d        hyperledger/fabric-ca        "sh -c 'fabric-ca-se…"   18 hours ago        Up 18 hours         0.0.0.0:7054-&gt;7054/tcp                           ca.org1.example.com
  c9b830eecf8a        hyperledger/fabric-ca        "sh -c 'fabric-ca-se…"   18 hours ago        Up 18 hours         7054/tcp, 0.0.0.0:8054-&gt;8054/tcp                 ca.org2.example.com
  </code></pre>
  
  <p>when I go inside peer0.org1.example.com or cli container and run 'peer channel..' commands its working fine without issues...</p>
  
  <pre><code>root@cead74ff3acf:/opt/gopath/src/github.com/hyperledger/fabric# peer channel list
  2020-03-04 07:55:39.000 UTC [channelCmd] InitCmdFactory -&gt; INFO 001 Endorser and orderer connections initialized
  Channels peers has joined: 
  </code></pre>
  
  <p>but when I go inside peer0.org2.example.com container and run them I'm getting the below error,</p>
  
  <pre><code>root@abd07c877081:/opt/gopath/src/github.com/hyperledger/fabric# peer channel list
  Error: error getting endorser client for channel: endorser client failed to connect to peer0.org2.example.com:10201: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.23.0.6:10201: connect: connection refused"
  </code></pre>
  
  <p>some warnings shown from peer0.org2 logs are,</p>
  
  <pre><code>[gossip.gossip] NewGossipService -&gt; WARN 017 External endpoint is empty, peer will not be accessible outside of its organization
  
  [gossip.comm] sendToEndpoint -&gt; WARN 103 Failed obtaining connection for , PKIid:1fff29d8bd80fe1df86bbd7b23f14059a0ad1ac10fd0e790b133d6f84433087d reason: context deadline exceeded
  
  [comm.grpc.server] 1 -&gt; INFO 122 unary call completed grpc.service=gossip.Gossip grpc.method=Ping grpc.request_deadline=2020-03-03T14:50:08.415Z grpc.peer_address=127.0.0.1:40334 grpc.code=OK grpc.call_duration=160.19µs
  [gossip.comm] func1 -&gt; WARN 123 127.0.0.1:7051, PKIid:1fff29d8bd80fe1df86bbd7b23f14059a0ad1ac10fd0e790b133d6f84433087d isn't responsive: EOF
  </code></pre>
  
  <p>Can you please identify the issue?</p>