C#: FTP Upload Error – The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

I developed an application a while back that automatically backs up a group of SQL servers every night and then uploads the backups to an offsite location using FTP. The application has worked flawlessly for months now so I was quite surprised to get a call this morning saying that the automatic backups failed last night. I checked the error logs and saw a 550 error – “The remote server returned an error: (550) File unavailable (e.g., file not found, no access).” I then ran the program through a debugger again saw that this exception was thrown while attempting to close the FileStream.

I tested for the usuals, spaces in the ftp uri, ensuring correct permissions for ftp user, changed the code around to see if it was a coding issue, and a bunch of other things and nothing seemed to fix the problem. I could login to the server with the same credentials using Windows Explorer and FileZilla and I could upload a test text file. I had no idea what was going on. So, after a long time, too long, I whipped out good ol’ WireShark to see if I could discern anything from the actual packet transfer (something I should have done first!) and lo and behold, there I found the error in plain text.

“There is not enough space on the disk.” Such a problem did not cross my mind as the hosting plan we pay for comes with unlimited disk space! Further, the test file I uploaded was a couple of KB rather than the 4 or 5 MB backups that were trying to be uploaded so I wasn’t seeing the error. Turns out despite what it says in the contract, there are still physical limits on the server. Ridiculous! :) After a short call to the hosting company the problem was resolved.

Despite the fact that the server was giving the real reason for the error, the .NET Framework did not relay the message. Kind of strange if you ask me but such is life. Nonetheless, a valuable lesson was learned: when debugging FTP issues, always pull out WireShark!

About these ads
Posted in .NET Framework. Tags: , , . 4 Comments »

4 Responses to “C#: FTP Upload Error – The remote server returned an error: (550) File unavailable (e.g., file not found, no access).”

  1. Mann Pang Says:

    I am having a similar issue whereby I can upload using FileZilla but not using the .NET code. What I can’t understand is that if you are running out of space, how did it work in FileZilla?

    • Nick Olsen Says:

      Maybe I didn’t make it clear in my post, but the only reason I could upload using FileZilla was that the file I used to upload was only 50 KB or so while the file I was trying to upload in my application was a couple of MB. When I tried to upload the large file in FileZilla, it failed as well. Sorry for the confusion. It sounds like you have a coding issue. What code are you using to upload via FTP? Maybe I can take a look and see if I can see an error.

      Have you tried running WireShark (or some other packet sniffer) while you execute your application to see what the actual error result is?

  2. joao Says:

    Some Linux FTP servers are case sensitive!

  3. Josh Says:

    Hi Nick,
    I’m running into the same issue with getting the error 550 command. I’m confused as to what is going wrong. Can you possibly tell me what I’m doing wrong in the following code?

    FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(ftpHost+ “/” + Path.GetFileName(“test2.txt”));
    request.Method = WebRequestMethods.Ftp.UploadFile;
    request.Credentials = new NetworkCredential(ftpUserNameTextBox.Text.Trim(), ftpPasswordTextBox.Text.Trim());
    request.UsePassive = true;
    request.UseBinary = true;
    request.KeepAlive = false;

    FileStream stream = File.OpenRead(Path.GetFileName(“test2.txt”));
    byte[] buffer = new byte[stream.Length];

    stream.Read(buffer, 0, buffer.Length);

    Stream reqStream = request.GetRequestStream();
    reqStream.Write(buffer, 0, buffer.Length);

    MessageBox.Show(“uploaded successfully”);
    catch (Exception ex)

    It is failing on the request.GetRequestStream() line. Any feedback would be greatly appreciated.

    Thanks so much!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 70 other followers

%d bloggers like this: