Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Can't connect to ipfs daemon from node 'ready' callback. #1207

Closed
@10thfloor

Description

@10thfloor
  • Version: js-ipfs version: 0.27.7
  • Platform: 17.3.0 Darwin Kernel Version 17.3.0: root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64

Type: Question

Severity: Low

Description:

Hello, I have a question about the intended functionality of the ipfs node instance.


const IPFS = require('ipfs');
const API = require('ipfs-api')

const node = new IPFS()

node.on('ready', () => {

    const ipfs = API('localhost', '5002', { protocol: 'http' })
   
    // Attempt to ask the API for anything. 
    // ipfs.id is used as an example here but all other methods fail.

    ipfs.id(function (err, identity) {
      if (err) {
        throw err
      }
      console.log(identity)
    })
})

Steps to reproduce the error:

Running the above code with node produces:

{ Error: connect ECONNREFUSED 127.0.0.1:5002
    at Object._errnoException (util.js:1031:13)
    at _exceptionWithHostPort (util.js:1052:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5002 }

I'm wondering if the ipfs constructor starts an ipfs daemon, or if the daemon must be started manually, from the cli?

Does new IPFS() start the ipfs daemon? The docs are unclear about this. (At least for me).

Thanks! ✌️

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/supportA question or request for support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions