Cannot connect to FTP in VM from internet

Salvador Rocha 5 Reputation points
2024-04-10T01:12:45.8366667+00:00

I've done all that I could find to allow connections to FTP to my virtual machine.

Virtual Machine running Windows Server 2016.

Opened ports in local firewall and NSG.

I can connect to FTP locally.

I cannot connect remotely

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,883 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,065 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2024-04-10T01:12:45.86+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    It seems like you have already opened the necessary ports in both your local firewall and NSG, and you are able to connect to FTP locally but not remotely. One thing to check is if you have enabled stateful FTP filtering that will dynamically open ports for data connections. To enable stateful FTP filtering, you can use the following command in a command prompt:

    netsh advfirewall set global StatefulFtp enable
    

    It's also important to note that active FTP connections may require an outbound connection from port 20 to be enabled on the server, and the FTP client machine would need to have its own firewall exceptions set up for inbound traffic. Additionally, FTP over SSL (FTPS) will not be covered by these rules, and you will need to configure your Windows Firewall settings for FTP differently if you intend to use FTP over SSL (FTPS).

    If you have already checked these settings and are still unable to connect remotely, you may want to check your network configuration and ensure that your VM is accessible from the internet.


    References:


  2. Prrudram-MSFT 24,546 Reputation points
    2024-04-10T07:38:11.28+00:00

    Hi @Salvador Rocha

    Glad to know your issue is resolved. In general, when you encounter this issue anytime again in future on any of the servers you can follow the below steps to identify the issue as the reboot may not be ideal thing to do all the time in case production workloads.

    First, you can check if the FTP service is running on your virtual machine. You can do this by opening the Command Prompt and running the following command:

    sc 
    

    This will show you the status of the FTP service. If it is not running, you can start it by running the following command:

    sc 
    

    Next, let's check if the FTP ports are open on your virtual machine. You mentioned that you have opened the ports in the local firewall and NSG, but let's double-check. You can use the following command to check if the FTP ports are open:

    telnet <VM IP 
    

    If the connection is successful, you will see a message that says "220 Microsoft FTP Service". If the connection is unsuccessful, you may need to check your firewall and NSG rules again to make sure that the FTP ports are open.

    If you are still unable to connect remotely, you may want to check if your FTP client is configured correctly. Make sure that you are using the correct IP address and port number to connect to your virtual machine. Also, make sure that you are using the correct username and password to authenticate.

    I hope this helps you troubleshoot such issues. If you have any further questions or concerns, please let me know.

    If I have answered your query, please click "Accept as answer" as a token of appreciation

    0 comments No comments

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.