File Transfer Protocol (FTP) is the standard protocol for transferring files between a client and a server. To establish a connection, you’ll need to use port numbers. But what does that mean? And what does the process entail?
Well, the FTP protocol uses two port numbers: 20 and 21. One is required to send FTP commands while the other is used to transfer files. Although it might sound technical, a good web hosting provider makes it relatively straightforward to establish an FTP connection.
In this post, we’ll take a closer look at FTP and the role of port 21. Then, we’ll show you how to configure your FTP client correctly and share some best practices for smooth file transfers. Let’s get started!
What Is FTP (File Transfer Protocol)?
FTP (File Transfer Protocol) is primarily used to move files between applications and computers. For example, if you create a new WordPress site, you could use FTP to upload the files from your personal device to the web server.
You could also use it to install plugins, upload media files, or troubleshoot issues when you don’t have access to the WordPress dashboard. With FTP, you can even copy, rename, edit, and delete WordPress files and folders.
Many popular web hosting providers offer an FTP server. However, you’ll also need an FTP client to connect to this server. FileZilla is a popular option.
To make a secure connection between the device and the server, you’ll need to use the right FTP port number. Only then can you begin the file transfer.
Port numbers are communication endpoints that identify the apps/services you want to access.
What Is the Role of FTP Port 21?
As we’ve just mentioned, an FTP port number is required to establish a secure connection between the device and the FTP server.
The port can use numbers between 0 and 65535. These numbers were assigned by the Internet Assigned Numbers Authority (IANA).
Port 21 is known as the default FTP port. You might be wondering why.
Well, port 21 can also be described as the command port or the control channel as it’s the first step to establishing a connection between the server and the client.
Note that port 21 isn’t used to send/receive the data itself. For that, you’ll use the data port (port 20).
Instead, its sole responsibility is to send FTP commands. For example, you can issue authentication commands (like PASS or USER), as well as mode commands and file commands (like PUT and GET).
In this instance, the client will deliver commands to the server, and the FTP server responds with a status code. As such, you’ll use this port to initiate and end data transfer sessions (but you’ll use port 20 to actually transmit the files).
Passive Mode vs Active Mode
There’s also a difference between FTP passive mode and active mode. This difference lies in the role of the server.
In active FTP mode, the server initiates the connection. In passive mode FTP, the server simply confirms the connection after the client initiates it.
But why would you need to use a passive FTP connection?
Well, if you use a firewall, it can block the connection between the client and the server.
However, you can work around this problem by using the port in passive mode. Since the client initiates the connection in this instance, it won’t trigger the firewall.
Note that port 21 is needed whether you use active or passive mode. Since port 20 is just used for transferring files, it isn’t required for passive FTP.
How to Establish an FTP Connection
If you want to connect to your WordPress files remotely, you’ll need an FTP client to establish a connection.
Once you’ve installed and launched the FTP software, you’ll need to enter your FTP login credentials. This information is usually available within your web hosting account.
You’ll then need to choose an FTP client like FileZilla. Some hosts like NameHero make things a bit easier by letting you set up the client/connection via your cPanel dashboard:
In this case, you’ll go to FTP Accounts where you can add an account or configure an FTP client.
Each client may look slightly different. With FileZilla, you have the option to use the Quick Connect method (if you’ve already established a previous connection).
Otherwise, you’ll need to go to Site Manager > New site and enter the relevant details including the server host’s key, username, password, and port number. Then, click on Connect:
If this is successful, two columns will appear in the interface. To the left, you’ll see the local files stored on your computer. To the right, you should see your website files, which are now accessible remotely.
If you right-click on a file, you can edit files, rename them, download folders to your device, and more:
Note that FTP works both ways, so you can also upload files from your computer to your WordPress site. This comes in handy when making tweaks to key website files like your .htaccess file or functions.php.
Best Practices for Smooth File Transfers
While we’ve shown you how to establish an FTP connection over port 21, there are additional considerations to ensure it all goes smoothly.
We’ll reiterate that if port 21 or port 20 are closed, you can’t establish an active FTP session. However, if you want to establish a passive connection, you only need port 21.
We also mentioned how firewalls can block the connection between the client and server, which is why you might opt for passive mode FTP. It’s also a good idea to configure firewall rules for port 21 to open it up for traffic.
If you continue to encounter connectivity issues, here are some common methods for fixing FTP errors:
- Check that the server hostname is correct (your host may use a separate hostname for FTP).
- Make sure you’re using the correct username and password.
- Increase the timeout settings within the FTP client (or set it to “0” so it never times out).
- Disable your firewall temporarily to determine whether it’s blocking the connection.
- Verify that you’re using the appropriate port for the protocol (or update it using FileZilla’s Site Manager).
- If none of the above works, try flushing your DNS cache.
Note that FTP connections over port 21 are not encrypted. This goes for usernames, passwords, and the files being transferred. As such, there are risks involved, especially if hackers manage to intercept the FTP session.
That’s why some website owners prefer SSH File Transfer Protocol (SFTP). This secure version of FTP is encrypted, making it harder for unauthorized users to gain access to your data.
There are additional differences between FTP and SFTP. For instance, SFTP uses port 22 instead of 21.
Conclusion
FTP is a convenient way to connect to your website files from your personal computer. You can also use it to move files between two websites. But to establish a connection, you’ll use port numbers 20 and 21.
Port 21 is used to send/receive FTP commands while port 20 is involved in the actual transmission of data. You may run into connectivity errors, especially if you use firewalls. Fortunately, you can use a passive connection or disable the firewall to fix this.
At NameHero, you can configure your FTP account and client directly from your cPanel dashboard. Better yet, some of our hosting plans come with free domains, SSL certificates, and security features like daily backups. Check out our packages today!
Sophia is a staff writer at WordCandy.co, where she produces quality blog content for WordPress plugin and theme developers, hosting providers, website development and design agencies, and other online businesses.
Leave a Reply