Search code examples
pythonftpxampp

Connect to FTP server through same network


I'm hosting my FTP through XAMPP, and I'm trying to access the FTP from my other PC, but I cant seem to connect. I wrote a python script, which works on the PC hosting the FTP, but not on my other PC.

# Import Module
import ftplib

# Fill Required Information
HOSTNAME = "10.224.18.9"
USERNAME = "z2067"
PASSWORD = "password"


# Connect FTP Server
ftp_server = ftplib.FTP(HOSTNAME, USERNAME, PASSWORD)

# force UTF-8 encoding
ftp_server.encoding = "utf-8"

# Get list of files
ftp_server.dir()

OUTPUT:

drwxr-xr-x 1 ftp ftp              0 Jan 07  2022 36890
drwxr-xr-x 1 ftp ftp              0 Jan 06  2022 37064
drwxr-xr-x 1 ftp ftp              0 Jan 06  2022 37072
-rw-r--r-- 1 ftp ftp            116 Jan 18  2022 desktop.ini

When I run it on my other PC i get the following error: TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

I was wondering what settings I have to change on my FTP server hosted by XAMPP, to be able to access this FTP from my other PC?

I have some settings pics here:

enter image description here

enter image description here

enter image description here

enter image description here


Solution

  • It looks like you are using the public IP address for the server. If both devices are in the same network I suggest trying the IP address visible inside that network instead.

    If you follow this tutorial: https://lazyadmin.nl/it/ipconfig-command/ you can find out what that IP address is for the computer you are running XAMPP on. It should look something like 192.168.x.x. Try using that in your python code instead '10.224.18.9'.