Search code examples
hyperledger-composer

Running composer-rest-server on a different port?


By default it is starting on 3000 which is being used by another process.

Is there a way to make it run on a different port?

~/git/my-test-network$ composer-rest-server -p hlfv1 -n my-test-network -i admin -s adminpw -N never
Discovering types from business network definition ...
Discovered types from business network definition
Generating schemas for all types in business network definition ...
Generated schemas for all types in business network definition
Adding schemas for all types to Loopback ...
Added schemas for all types to Loopback
events.js:160
  throw er; // Unhandled 'error' event
  ^

Error: listen EADDRINUSE 0.0.0.0:3000
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at Server._listen2 (net.js:1258:14)
at listen (net.js:1294:10)
at net.js:1404:9
at _combinedTickCallback (internal/process/next_tick.js:83:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

Solution

  • Use the -P flag.

    daniels-mbp-2:composer-common dselman$ composer-rest-server --help
    Usage: composer-rest-server [options]
    
    Options:
      -p, --connectionProfileName  The connection profile name  [string]
      -n, --businessNetworkName    The business network identifier  [string]
      -i, --enrollId               The enrollment ID of the user  [string]
      -s, --enrollSecret           The enrollment secret of the user  [string]
      -N, --namespaces             Use namespaces if conflicting types exist  [string] [choices: "always", "required", "never"] [default: "always"]
      -P, --port                   The port to serve the REST API on  [number]
      -S, --security               Enable security for the REST API  [boolean] [default: false]
      -h, --help                   Show help  [boolean]
      -v, --version                Show version number  [boolean]