mscdex/node-ftp

Error: connect ECONNREFUSED 127.0.0.1:21

NeevJewalkar opened this issue · 2 comments

I am new to ftp, so i tried one of the examples

var Client = require('ftp');
  var fs = require('fs');
 
  var c = new Client();
  c.on('ready', function() {
    c.put('foo.txt', 'foo.remote-copy.txt', function(err) {
      if (err) throw err;
      c.end();
    });
  });
  // connect to localhost:21 as anonymous
  c.connect();

I created the foo.txt file, having 'test' in it
when i run the script, it gives me the error

events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:2
1```

please help me, i dont know what i am doing wrong

You need to pass the connection parameters:

c.connect({
  host: '',
  password: '',
  user: ''
})

works now, thanks!