Unable to download files from FTP server

36548900 20 Reputation points
2023-06-20T05:11:38.54+00:00

enter image description here

Problem Description: I put a file on FTP server (server created in Windows 10) so clients can download that file. The problem is that clients connected to the Internet with valid IP addresses can download this file, but clients connected to the Internet with dynamic IP addresses cannot download this file. The download operation is performed by a module written in VBA Excel. There is exactly the same problem in executing commands that are sent in the Windows command line. I have attached the image of these instructions. I don't know where the problem is. Please guide me to solve this problem. Thank you. The first image: Command lines were sent by a computer connected to the Internet with a dynamic IP, which eventually encountered an error in downloading the file. Figure 2: Command lines are sent by a computer connected to the Internet with a static IP, which ultimately results in receiving the file.


Windows development | Internet Information Services
Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
Windows for business | Windows Client for IT Pros | User experience | Other
{count} votes

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2023-06-21T18:30:35.3166667+00:00

    This should work as a PowerShell replacement for the VB code you posted:

    Add-Type -AssemblyName PresentationFramework
    Function FtpDownload{
        param(
            [string]$RemoteFile,
            [string]$LocalFile,
            [string]$HostName,
            [string]$User,
            [string]$Pass
        )
        $ftp = "ftp://{0}:{1}@{2}{3}" -f $User,$Pass,$HostName,$RemoteFile
        $uri = New-Object -TypeName System.Uri -ArgumentList $ftp
        $webclient = New-Object -TypeName System.Net.WebClient
        $webclient.DownloadFile($uri, $File)
    }
    
    Function DownLoad{
        Try{
            FtpDownload -RemoteFile "/public_ftp/text.txt" `
                        -LocalFile  "D:\town finance/text.txt" `
                        -HostName   "server10.dn-server.com" `
                        -User       "xxxxxx" `
                        -Pass       "nnnnnn"
            [System.Windows.MessageBox]::Show("download ok","Pars Royan","OK","Information") | Out-Null
        }
        Catch{
            [System.Windows.MessageBox]::Show('fail',"Pars Royan","OK","Error") | Out-Null
        }
    }
    
    1 person found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2023-06-20T15:12:00.54+00:00

    The client-side FTP protocol (in "active mode", which is the default) expects the FTP server to open an outbound connection to the FTP client -- and the server uses the IP address sent by the client. In the case of a client using dynamically assigned IP address, that IP address is on an unreachable (private) network.

    To remedy this, the FTP client should use passive mode and the server will then, usually make the connection using a reachable address. This doesn't always work. Also, I don't think the FTP client supplied by Windows supports the use of passive mode.

    Most 3rd party FTP client support passive mode connection. You can also using a web browser (by using the "ftp://" protocol).


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Limitless Technology 44,766 Reputation points
    2023-06-20T20:34:54.68+00:00

    Hello,

    Thank you for your question and for reaching out with your question today.

    Based on the information provided, it seems that clients with dynamic IP addresses are experiencing issues downloading a file from the FTP server, while clients with static IP addresses can download the file successfully.

    One possible reason for this issue is that the FTP server has some restrictions or access controls in place that prevent clients with dynamic IP addresses from accessing and downloading files. It's common for FTP servers to have security measures to limit access to certain IP ranges or to require authentication for downloading files.

    To troubleshoot and resolve this problem, you can consider the following steps:

    1. Check the FTP server's configuration: Review the FTP server's settings and configuration to see if there are any IP-based access restrictions in place. Look for settings related to IP whitelisting or blacklisting and ensure that clients with dynamic IP addresses are not blocked.
    2. Verify client connectivity: Ensure that clients with dynamic IP addresses have a stable and functional internet connection. Sometimes, connectivity issues or network problems can affect the ability to download files from an FTP server.
    3. Test FTP connection from different locations: Try connecting to the FTP server from multiple locations with dynamic IP addresses. This will help determine if the issue is specific to certain IP ranges or if it affects all dynamic IP addresses. If the issue is consistent across different locations, it's more likely related to the FTP server configuration.
    4. Contact the FTP server administrator: If you don't have direct control over the FTP server, reach out to the administrator or hosting provider to discuss the issue. Provide them with the details of the problem and the error messages received during the download attempts. They should be able to assist you in troubleshooting and resolving any server-side restrictions or configuration issues.

    By investigating the FTP server's configuration, verifying client connectivity, testing connections from different locations, and reaching out to the server administrator, you should be able to identify the cause of the problem and take appropriate steps to resolve it.

    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.

    If the reply was helpful, please don’t forget to upvote or accept as answer.


  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.