title: panic: Error initializing ledger provider: unable to connect to CouchDB, check the hostname and port: Get http://couchdb1:5984/: EOF
body: <p>I am trying to start a hyperledger fabric network in Linux (RHEL 7) machine with <code>docker-compose</code>. But the peer containers are exiting after some time. In the <code>peer</code> container logs I can see below error. </p>
  
  <pre><code>2020-02-20 02:25:29.963 UTC [nodeCmd] serve -&gt; INFO 001 Starting peer:
   Version: 1.4.4
   Commit SHA: 7917a40
   Go version: go1.12.12
   OS/Arch: linux/amd64
   Chaincode:
    Base Image Version: 0.4.18
    Base Docker Namespace: hyperledger
    Base Docker Label: org.hyperledger.fabric
    Docker Namespace: hyperledger
  2020-02-20 02:25:29.964 UTC [ledgermgmt] initialize -&gt; INFO 002 Initializing ledger mgmt
  2020-02-20 02:25:29.964 UTC [kvledger] NewProvider -&gt; INFO 003 Initializing ledger provider
  2020-02-20 02:25:30.032 UTC [kvledger] NewProvider -&gt; INFO 004 ledger provider Initialized
  2020-02-20 02:25:30.200 UTC [couchdb] handleRequest -&gt; WARN 005 Retrying couchdb request in 125ms. Attempt:1  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:25:30.386 UTC [couchdb] handleRequest -&gt; WARN 006 Retrying couchdb request in 250ms. Attempt:2  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:25:30.689 UTC [couchdb] handleRequest -&gt; WARN 007 Retrying couchdb request in 500ms. Attempt:3  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:25:31.241 UTC [couchdb] handleRequest -&gt; WARN 008 Retrying couchdb request in 1s. Attempt:4  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:25:32.294 UTC [couchdb] handleRequest -&gt; WARN 009 Retrying couchdb request in 2s. Attempt:5  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:25:34.347 UTC [couchdb] handleRequest -&gt; WARN 00a Retrying couchdb request in 4s. Attempt:6  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:25:38.401 UTC [couchdb] handleRequest -&gt; WARN 00b Retrying couchdb request in 8s. Attempt:7  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:25:46.455 UTC [couchdb] handleRequest -&gt; WARN 00c Retrying couchdb request in 16s. Attempt:8  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:26:02.510 UTC [couchdb] handleRequest -&gt; WARN 00d Retrying couchdb request in 32s. Attempt:9  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:26:34.565 UTC [couchdb] handleRequest -&gt; WARN 00e Retrying couchdb request in 1m4s. Attempt:10  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:27:38.620 UTC [couchdb] handleRequest -&gt; WARN 00f Retrying couchdb request in 2m8s. Attempt:11  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:29:46.675 UTC [couchdb] handleRequest -&gt; WARN 010 Retrying couchdb request in 4m16s. Attempt:12  Error:Get http://couchdb1:5984/: EOF
  2020-02-20 02:34:02.731 UTC [couchdb] handleRequest -&gt; WARN 011 Retrying couchdb request in 8m32s. Attempt:13  Error:Get http://couchdb1:5984/: EOF
  panic: Error initializing ledger provider: unable to connect to CouchDB, check the hostname and port: Get http://couchdb1:5984/: EOF
  
  goroutine 1 [running]:
  github.com/hyperledger/fabric/core/ledger/ledgermgmt.initialize(0xc0003728c0)
          /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/ledgermgmt/ledger_mgmt.go:81 +0x78a
  github.com/hyperledger/fabric/core/ledger/ledgermgmt.Initialize.func1()
          /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/ledgermgmt/ledger_mgmt.go:53 +0x2a
  sync.(*Once).Do(0x26d0748, 0xc0001ff458)
          /opt/go/src/sync/once.go:44 +0xb3
  github.com/hyperledger/fabric/core/ledger/ledgermgmt.Initialize(0xc0003728c0)
          /opt/gopath/src/github.com/hyperledger/fabric/core/ledger/ledgermgmt/ledger_mgmt.go:52 +0x55
  github.com/hyperledger/fabric/peer/node.serve(0x26d0668, 0x0, 0x0, 0x0, 0x0)
          /opt/gopath/src/github.com/hyperledger/fabric/peer/node/start.go:181 +0x568
  github.com/hyperledger/fabric/peer/node.glob..func3(0x25c7240, 0x26d0668, 0x0, 0x0, 0x0, 0x0)
          /opt/gopath/src/github.com/hyperledger/fabric/peer/node/start.go:126 +0xf1
  github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).execute(0x25c7240, 0x26d0668, 0x0, 0x0, 0x25c7240, 0x26d0668)
          /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:762 +0x465
  github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x25c7960, 0xc0001fff60, 0x1, 0x1)
          /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:852 +0x2ec
  github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).Execute(...)
          /opt/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:800
  main.main()
          /opt/gopath/src/github.com/hyperledger/fabric/peer/main.go:53 +0x41f
  </code></pre>
  
  <p>I suspected there could be some dns issue in the docker container. So I have also tried 
  adding <code>dns_search: .</code> and <code>- GODEBUG=netdns=go</code> in the <code>docker-compose.yaml</code> file.</p>
  
  <pre><code>  peer0.org1.example.com:
      container_name: peer0.org1.example.com
      image: hyperledger/fabric-peer:1.4.4
      dns_search: .
      environment:
        - GODEBUG=netdns=go
        - CORE_PEER_ID=peer0.org1.example.com
        - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
        - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:7051
        - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
        - CORE_PEER_LOCALMSPID=Org1MSP
        - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
        - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_example
        - FABRIC_LOGGING_SPEC=INFO
        - CORE_PEER_TLS_ENABLED=true
        - CORE_PEER_GOSSIP_USELEADERELECTION=true
        - CORE_PEER_GOSSIP_ORGLEADER=false
        - CORE_PEER_PROFILE_ENABLED=true
        - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
        - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
        - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
        - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
        - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
        - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin
        - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=admin
  
  </code></pre>
  
  <p>It is still the same error. </p>