Set Up an Android FTP Server Using Termux

12 min read Learn step‑by‑step how to turn your Android phone into an FTP server using Termux, so you can move files over Wi‑Fi without rooting or third‑party apps. September 27, 2026 13:30 How to Set Up an Android FTP Server with Termux for Easy Wi‑Fi File Transfers

Transferring large files between a PC and an Android device often means juggling USB cables, cloud services, or paid apps. If you have a stable Wi‑Fi network, an FTP server running directly on your phone gives you a fast, cable‑free solution that works on any platform supporting FTP.

Why Use Termux for an FTP Server?

Termux is a lightweight terminal emulator and Linux environment for Android. It runs without root, installs packages from the same repositories used on Debian/Ubuntu, and lets you execute standard command‑line tools. By using Termux you avoid:

  • Installing bulky GUI FTP apps that run background services.
  • Granting unnecessary permissions to third‑party apps.
  • Relying on a PC‑side server that must stay on while you move files.

With a few commands you get a fully functional FTP server that serves any folder you choose, and you can stop it instantly when you’re done.

Before You Start

  • Battery: Keep your phone plugged in or at least 50 % charged. Running an FTP server can keep the CPU active for a while.
  • Network: Both the Android device and the client computer must be on the same Wi‑Fi network (same subnet). Verify the Wi‑Fi signal is strong.
  • Storage Permissions: Termux needs permission to read/write external storage. We’ll request this during setup.
  • Security Awareness: An FTP server transmits data unencrypted. Use it only on trusted home networks and consider a strong password.

Step 1 – Install Termux

  1. Open the Google Play Store (or F-Droid for the latest builds) and search for Termux.
  2. Tap Install. The download size is under 10 MB.
  3. Once installed, launch Termux from the app drawer.
  4. When the terminal opens for the first time, it will finish extracting its base files. This may take a minute.

After the initial setup you’ll see a prompt that looks like username@localhost:~$. This is your Linux‑like shell.

Step 2 – Update Packages and Install Required Tools

  1. Update the package index:
    pkg update
  2. Upgrade any out‑of‑date packages (optional but recommended):
    pkg upgrade
  3. Install python and openssh (the latter provides the ssh‑keygen utility we’ll use to create a password file):
    pkg install python openssh
  4. Give Termux permission to access external storage. Run:
    termux-setup-storage
    You’ll be prompted to allow “Files and media”. Accept.

Now you have a full Python interpreter and the ability to read files from the shared /sdcard directory.

Step 3 – Install a Lightweight FTP Server

We’ll use the pure‑Python pyftpdlib library because it’s easy to install and runs with a single command.

  1. Install the library via pip (Python’s package manager):
    pip install pyftpdlib
  2. Verify the installation succeeded:
    python -c "import pyftpdlib; print('pyftpdlib version', pyftpdlib.__version__)"

If you see a version number printed, the server is ready.

Step 4 – Choose a Directory to Share

Termux sees your shared storage under /sdcard. You can create a dedicated folder, for example /sdcard/FTPShare:

  1. Create the folder:
    mkdir -p /sdcard/FTPShare
  2. Optionally move existing files you want to share into this folder using the Android file manager or a PC.

Any file placed in FTPShare will be visible to FTP clients.

Step 5 – Create a Simple Password File (Optional but Recommended)

By default pyftpdlib runs an anonymous server, meaning anyone on the network can read (and possibly write) files. To restrict access:

  1. Create a file called users.txt inside the shared folder:
    echo "myuser:mystrongpassword" > /sdcard/FTPShare/users.txt
  2. We’ll tell the server to use this file for authentication.

Replace myuser and mystrongpassword with something you can remember but is not obvious.

Step 6 – Launch the FTP Server

Run the following one‑liner. It starts the server on port 2121 (chosen to avoid the default FTP port 21, which is often blocked on Wi‑Fi routers) and points it at the FTPShare folder.

python -m pyftpdlib -p 2121 -w -d /sdcard/FTPShare -P /sdcard/FTPShare/users.txt

Explanation of the flags:

  • -p 2121 – listen on port 2121.
  • -w – enable write permissions for authenticated users.
  • -d /sdcard/FTPShare – set the home directory for all sessions.
  • -P /sdcard/FTPShare/users.txt – use the password file for login.

After you press Enter, you should see a line similar to:

pyftpdlib FTP server listening on 0.0.0.0:2121

This means the server is active and waiting for connections.

Step 7 – Find Your Phone’s IP Address

On the same Termux session, type:

ip addr show wlan0

Look for the line containing inet. It will look like 192.168.1.45/24. The part before the slash (e.g., 192.168.1.45) is the IP you’ll use on the client.

Step 8 – Connect from a PC or Another Device

Use any FTP client (FileZilla, WinSCP, the built‑in Windows Explorer, or even a web browser) and enter:

  • Host: ftp://192.168.1.45:2121 (replace with your IP)
  • Username: myuser
  • Password: mystrongpassword

When the connection succeeds you’ll see the contents of FTPShare. Drag and drop files to upload or download.

Step 9 – Verify Transfer Success

After copying a file, refresh the FTP client view. The file should appear instantly. On Android you can open the FTPShare folder with the Files app to confirm the file exists.

Step 10 – Stop the Server When Finished

Return to the Termux window where the server is running and press Ctrl +C. You’ll see a message like KeyboardInterrupt and the prompt will return, indicating the server has stopped.

Alternative Methods

If you prefer a GUI approach or need additional features (e.g., TLS encryption), consider these options:

  • FTP Server apps: “Wi‑Fi FTP Server” or “FTP Server” from the Play Store. They provide a one‑tap interface but often require more permissions.
  • SFTP via OpenSSH: Install openssh in Termux and run sshd. SFTP encrypts traffic, but you’ll need an SSH client on the PC.

The Termux method stays lightweight, gives you full control, and works on any Android version that supports Termux (Android 5.0+).

Troubleshooting

1. Cannot Connect – “Connection timed out”

  • Make sure both devices are on the same Wi‑Fi network. Some routers create “guest” networks that isolate clients.
  • Check the phone’s IP address again; it may have changed after a Wi‑Fi reconnection.
  • Verify the port is not blocked by the router. Try a different port, e.g., 2122, by changing -p 2122 in the launch command.

2. Permission Denied When Accessing Files

  • Ensure you ran termux-setup-storage and accepted the permission dialog.
  • Confirm the FTP server was started with the -d /sdcard/FTPShare flag pointing to the exact folder.

3. Unexpected Disconnections

  • Android may put the Wi‑Fi radio to sleep if the screen is off for a long time. Keep the screen on or enable “Keep Wi‑Fi on during sleep” in Settings → Wi‑Fi → Advanced.
  • If you see OSError: [Errno 98] Address already in use, another process is already listening on the chosen port. Stop the previous server (Ctrl +C) or pick a free port.

Safety and Privacy Tips

  • Use a strong password. Even on a home network, a weak password can be guessed by anyone with network access.
  • Limit the shared folder. Only expose the FTPShare directory; keep sensitive files elsewhere.
  • Prefer SFTP for confidential data. If you need encryption, replace the FTP command with sshd and connect via SFTP.
  • Turn off the server when not in use. Leaving it running unnecessarily widens the attack surface.

Wrap‑Up

By following these steps you now have a fully functional FTP server running on your Android phone, powered by Termux. The setup is lightweight, reversible, and works without rooting. Whether you need to move photos, backup documents, or quickly share a video with a laptop, the server provides a fast, cable‑free workflow that you control from the command line.

Remember to shut down the server with Ctrl +C when you’re finished, and keep the password file secure. For encrypted transfers, switch to SFTP – the same Termux environment makes that transition painless.

User Comments (0)

Add Comment
We'll never share your email with anyone else.