go – goftp is throwing 502 error on every command-ThrowExceptions

Exception or error:

I’m trying to implement FTP client in golang. I’m using goftp library to do that. I’m able to login to the FTP server successfully, but after that every command (get the present working directory, upload a file etc) is throwing panic: 502 Command not implemented. exception. For example, in the below code, I’m trying to get the present working directory after logging in to the server.

I’m able to do all kinds of operations through conventional ftp commands through CLI. But, here I’m blocked with 502 error code. Is there anything I’m missing here?

import (

    goftp "gopkg.in/dutchcoders/goftp.v1"

// Actual code
if ftp, err = goftp.Connect(host); err != nil {

defer ftp.Close()
fmt.Println("Successfully connected to", host)

if err = ftp.Login(username, password); err != nil {

pwd, err := ftp.Pwd()
if err == nil {
    fmt.Println("present working directory:", pwd)
} else {


After enabling debug mode (using goftp.ConnectDbg(host)), I got following log:

2019/10/25 22:26:03 < 220 Service ready for new user.

2019/10/25 22:26:03 220 Service ready for new user.

2019/10/25 22:26:03 > USER pkgajulapalli

2019/10/25 22:26:03 < 331 User name okay, need password for pkgajulapalli.

2019/10/25 22:26:03 > PASS password@123

2019/10/25 22:26:03 < 230 User logged in, proceed.

Logged in with credentials

2019/10/25 22:26:05 > PWD

2019/10/25 22:26:05 < 502 Command not implemented.

panic: 502 Command not implemented.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *