Hafeez Khan
Hafeez Khan

Reputation: 487

Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED

I am trying to run the Hyperledger fabric Tuna app and getting the below error when running the regiseterAdmin.js

  Store path:/home/chaindev/.hfc-key-store
Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]
    at ClientRequest.<anonymous> (/home/chaindev/fabricProjects/src/github.com/education/LFS171x/fabric-material/tuna-app/node_modules/fabric-ca-client/lib/FabricCAClientImpl.js:711:12)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
Failed to enroll admin: Error: Failed to enroll admin

Upvotes: 3

Views: 11542

Answers (7)

邓思远
邓思远

Reputation: 1

I have the same error. I run networkDown.sh and the run startFabric.sh again.Then it succeeded.

Upvotes: 0

Shubham Chadokar
Shubham Chadokar

Reputation: 2763

Run docker ps and check if all the docker containers are running or not.

If it is not running run it, if it fail, download the fabric binaries.

Upvotes: 0

Chirag
Chirag

Reputation: 11

This can also happen if the port in [email protected] does not match the port in docker-compose.yaml, I had hard time finding solution to this problem.

Upvotes: 1

Subhod I
Subhod I

Reputation: 182

Mismatch in connection protocols, either you have done fabric setup without TLS and trying to connect to CA using https protocol or vice-versa.

Upvotes: 0

Ahsan Nabi Khan
Ahsan Nabi Khan

Reputation: 21

The docs need be updated on this. Localhost 127.0.0.1 does not work for Docker For Windows and Docker Toolbox as they both give their run-time IP address on start of Docker (here taken as 192.168.1.2). This start-up IP needs to be updated in the registerAdmin.js file (or in my case enrollAdmin.js file as referred in the Tutorial "Writing First App" ). The enrollAdmin.js needs be updated in this line:

// be sure to change the http to https when the CA is running TLS enabled
    fabric_ca_client = new Fabric_CA_Client('http://192.168.1.2:7054', tlsOptions , 'ca.example.com', crypto_suite);

The output certificate should be like:

Successfully enrolled admin user "admin"
Assigned the admin user to the fabric client :: "name":"admin","mspid":"Org1MSP","roles":null,"affiliation":"","enrollmentSecret":"","enrollment": "signingIdentity":"c198861140fc723abc058c70d23395a2d7b73c926ca673b53d713053aaade419","identity":{"certificate":"-----BEGIN CERTIFICATE-----\nMIICATCCAaigAwIBAgIUK/o2ege+nT73jK/NXSgYIKoZIzj0EAwIw\nczELM...QnCkD6AiApKxxU1maQIt1TKFl3KYZWGBNDSSa6SCbob7q1p5xfpQ==\n-----END CERTIFICATE-----\n"}}}

Similar problem solved here.

Upvotes: 2

Hafeez Khan
Hafeez Khan

Reputation: 487

The issue was occurring for me because I had the wrong Private Key name mentioned in the docker-compose.yml file
FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/4239aa0dcd76daeeb8ba0cda701851d14504d31aad1b2ddddbac6a57365e497c_sk
When I re-generated the artificats the key file name was changed and after correction everything worked fine.
Also thanks for rocket-fabric group for mentioning the commands on how to look for logs in docker container. Below commands can be useful to debug

docker ps -a 

docker logs <ca container name>

Upvotes: 5

Monarth Sarvaiya
Monarth Sarvaiya

Reputation: 1126

As your .hfc-key-store directory is in chaindev,

Try running the following commands:

$ cd ~/chaindev/
$ rm -rf .hfc-key-store/

Then, run the command:

$ node registerAdmin.js

Upvotes: 1

Related Questions