Change vsftpd FTP Server Port Number 21

Because of security issues I would like to change the vsftpd server tcp port # 21. How do I configure vsftpd to use another port instead of the default TCP port 21? How to change vsftpd ftp port number in Linux or Unix?

vsftpd, which stands for Very Secure FTP Daemon, is an FTP server under Ubuntu, Fedora Core, Red Hat Enterprise Linux and a number of other distributions. Changing a default port is a good idea. FTP is a common method for allowing remote access to files. Like telnet, the FTP protocol is unencrypted, which means that passwords and other data transmitted during the session can be captured and that the session is vulnerable to hijacking.
Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements vsftpd
Linux or Unix
Time N/A

Changing vsftp port

All you need to do is edit the configuration file for vsftpd server. The default configuration file is /etc/vsftp/vsftpd.conf or /etc/vsftpd.conf.

First login as root user.

Open the vsftpd.conf file, enter:
# vi vsftpd.conf

Find line that read as follows

Replace port 21 with new port such as 201:

Save and close the file. Please make sure no other service is using port # 201. Finally, restart the vsftpd server:
# /etc/init.d/vsftpd restart
# service vsftpd restart

All ftp client need use the tcp port # 201 while connecting to the ftp server. For example:
$ ftp 201

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 13 comments so far... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
13 comments… add one
  • Dhiraj Jan 10, 2007 @ 12:30

    After changing the default port number not able to use ftp service from outside network. From Lan it is working fine

  • 🐧 nixCraft Jan 10, 2007 @ 13:52


    Make sure new port is open at firewall.

  • Bob Dec 7, 2009 @ 17:41

    @Dhiraj, Also make sure the chosen port is opened by port forwarding.

  • jake Feb 3, 2010 @ 5:46

    Thanks, works like a charm.

  • somanath Aug 5, 2010 @ 9:45

    Thanks. It is working great.

  • Arfat Mar 23, 2012 @ 13:18

    When i changes the default port from 21 to 115. My vsftpd service fail to start.
    OS ver- RHEL6.1
    IPTables – OFF.
    Selinux – Enforcing Mode.

    Please help.

    • linuxender May 4, 2012 @ 22:09

      Its a bug that Selinux wont allow vsftpd to be started if you have assigned the port which is less then 1024 except port number 21. Assign the port which greater than 1024, for e.g. try port 10000. vsftpd will not fail to start.

  • David Jun 20, 2012 @ 8:46

    Thanks. I only had to add this line:


    and restart the service.

  • Nasa Nov 28, 2012 @ 20:39

    Excellent article, simple and informative!! I think there is a typo in last line “Client need to use port 21 while connecting to ftp server” shouldn’t it be 201?

  • Mike Angels Feb 2, 2013 @ 13:47

    You should not use any port below 1024 because they are reserved for specific tasks
    going above 20 000 can cause problem when you are using low quality hardware such as routers.
    also for FTP if you choose a port ending with 21 that can give a hint that it is a FTP (ex: 1721, 3421 or 7721) so use something like 8349.

    If you want maximum security you can configure SFTP (secure ftp) instead.
    Best regards

  • bn8595 Aug 13, 2013 @ 10:43

    is there any file in Linux where port numbers are predefined / listed ?

    • Octo Aug 22, 2013 @ 21:07


      cat /etc/services

  • ctechz Nov 26, 2013 @ 19:14

    when we change the incoming port 21 to some other and what outgoing port the server will take, 20 or some other

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @