mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 244 forks source link

Error: connect ECONNREFUSED 127.0.0.1:21 #273

Closed ghost closed 3 years ago

ghost commented 3 years ago

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
mateus4k commented 3 years ago

You need to pass the connection parameters:

c.connect({
  host: '',
  password: '',
  user: ''
})
ghost commented 3 years ago

works now, thanks!