EOF Error with ftplib only when connecting to GoDaddy hosted server
<p>I'm having problems with FTP_TLS (ftplib) in Python 2.7.3.</p>

<p>Summary of findings (all connection attempts performed over the internet):</p>

<ul>
<li>FileZilla to home web server - works</li>
<li>FileZilla to GoDaddy shared hosting server - works</li>
<li>Python to home web server - works</li>
<li>Python to GoDaddy shared hosting server - fails (see stack trace below)</li>
</ul>

<p>The following code shows how I reproduce the problem. When connecting to my home server, this code generates an identical log on my personal FTP as FileZilla. (Only when connecting to the GoDaddy site does it result in an EOF exception).</p>

<pre><code>from ftplib import FTP_TLS
o = FTP_TLS(ftpServer,ftpUsername,ftpPassword,ftpPort)
o.voidcmd('SYST')
o.voidcmd('FEAT')
o.prot_p()
o.voidcmd('PWD')
o.retrbinary('MLSD', open('OUTTEST', 'wb').write)
&gt;&gt;&gt; o.retrbinary('MLSD', open('OUTTEST', 'wb').write)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/lib/python2.7/ftplib.py", line 703, in retrbinary
    return self.voidresp()
  File "/usr/lib/python2.7/ftplib.py", line 225, in voidresp
    resp = self.getresp()
  File "/usr/lib/python2.7/ftplib.py", line 211, in getresp
    resp = self.getmultiline()
  File "/usr/lib/python2.7/ftplib.py", line 197, in getmultiline
    line = self.getline()
  File "/usr/lib/python2.7/ftplib.py", line 187, in getline
    if not line: raise EOFError
</code></pre>

<p>I read that the EOF error is given when the server closes the pipe. It's also similar to what happens if you change to prot_p and then try to issue a plain text command (although as far as I can tell, this isn't the case here).</p>

<p>I don't understand what's different between my code and FileZilla. The fact that all attempts are performed over the internet reassures me that it isn't related to firewalls. Furthermore, FileZilla works, so from a technical perspective the connection is possible, I'm just having a hard time achieving it with Python.</p>

<p>My code works with the GoDaddy FTP if I don't issue the prot_p switch.</p>

<p>Additional information:</p>

<ul>
<li>GoDaddy doesn't provide technical FTP logs (only usage logs)</li>
<li>My code has been working flawlessly for over a year, this just started happening two months ago.</li>
<li>The GoDaddy FTP server identifies as "Pure-FTPd [privsep] [TLS]"</li>
</ul>

<p>Typical FileZilla Server Log after running my code.</p>

<pre><code>(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; Connected on port 21, sending welcome message...
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; 220-FileZilla Server 0.9.57 beta
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; 220-written by Tim Kosse (Tim.Kosse@gmx.de)
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; 220 Please visit https://filezilla-project.org/
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; AUTH TLS
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; 234 Using authentication type TLS
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; SSL connection established
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; USER ********************
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; 331 Password required for USER_NAME
(000132)18/10/2016 15:44:19 - (not logged in) (IP_ADDRESS)&gt; PASS ********************
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; 230 Logged on
(000131)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; disconnected.
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; SYST
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; 215 UNIX emulated by FileZilla
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; FEAT
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; 211-Features:
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  MDTM
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  REST STREAM
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  SIZE
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  MODE Z
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  MLST type*;size*;modify*;
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  MLSD
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  AUTH SSL
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  AUTH TLS
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  PROT
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  PBSZ
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  UTF8
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  CLNT
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  MFMT
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  EPSV
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt;  EPRT
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; 211 End
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; PBSZ 0
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; 200 PBSZ=0
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; PROT P
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; 200 Protection level set to P
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; PWD
(000132)18/10/2016 15:44:19 - USER_NAME (IP_ADDRESS)&gt; 257 "/" is current directory.
(000132)18/10/2016 15:44:22 - USER_NAME (IP_ADDRESS)&gt; TYPE I
(000132)18/10/2016 15:44:22 - USER_NAME (IP_ADDRESS)&gt; 200 Type set to I
(000132)18/10/2016 15:44:22 - USER_NAME (IP_ADDRESS)&gt; PASV
(000132)18/10/2016 15:44:22 - USER_NAME (IP_ADDRESS)&gt; 227 Entering Passive Mode (xxx,xxx,xxx,xxx,xxx,xxx)
(000132)18/10/2016 15:44:22 - USER_NAME (IP_ADDRESS)&gt; MLSD
(000132)18/10/2016 15:44:22 - USER_NAME (IP_ADDRESS)&gt; 150 Opening data channel for directory listing of "/"
(000132)18/10/2016 15:44:22 - USER_NAME (IP_ADDRESS)&gt; SSL connection for data connection established
(000132)18/10/2016 15:44:22 - USER_NAME (IP_ADDRESS)&gt; 226 Successfully transferred "/"
</code></pre>

<p>I think you need to set the FTP mode to passive, here's a <a href="http://www.perlmonks.org/?node_id=175281" rel="nofollow">similar error but in Perl</a></p>

<p>The difference is explained in <a href="http://stackoverflow.com/questions/1699145/what-is-the-difference-between-active-and-passive-ftp">what-is-the-difference-between-active-and-passive-ftp</a></p>

python python-2.7 ftplib