<p>I am running the version 6.5.7. I got the same issue at first as OP, but then got this one, and now it seems to be going fine... (there is a lot of mail to retrieve though). Maybe this log will help you somehow.</p>

<div class="highlight highlight-source-ini"><pre><span class="pl-en">[general]</span>
<span class="pl-k">accounts</span> = gmail

<span class="pl-en">[Account gmail]</span>
<span class="pl-k">localrepository</span> = Local
<span class="pl-k">remoterepository</span> = Remote
<span class="pl-k">status_backend</span> = sqlite

<span class="pl-en">[Repository Local]</span>
<span class="pl-k">type</span> = Maildir
<span class="pl-k">localfolders</span> = ~/.mail/gmail

<span class="pl-en">[Repository Remote]</span>
<span class="pl-k">type</span> = Gmail
<span class="pl-k">remoteuser</span> = ***
<span class="pl-k">remotepass</span> = ***
<span class="pl-k">sslcacertfile</span> = /etc/ssl/certs/ca-certificates.crt
<span class="pl-k">folderfilter</span> = lambda folder: folder not in [<span class="pl-s"><span class="pl-pds">'</span>[Gmail]/All Mail<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>[Gmail]/Bin<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>[Gmail]/Drafts<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>[Gmail]/Spam<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>SentMail<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>Trash<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>AllMail<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>Queue<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>Drafts<span class="pl-pds">'</span></span>]</pre></div>

<pre lang="log"><code>2015-10-24 20:16:50 DEBUG: [imap]:   16:50.09 Copy message from Remote:[Gmail]/Important [sync] EXAMINE ('[Gmail]/Important',)
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 imap.gmail.com reader socket error: <class 'socket.error'> - [Errno 104] Connection reset by peer
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 imap.gmail.com reader finished
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 imap.gmail.com handler terminating: "socket error: <class 'socket.error'> - [Errno 104] Connection reset by peer"
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 imap.gmail.com handler EXAMINE:MNPA92.ready.set
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 imap.gmail.com writer finished
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 imap.gmail.com handler state_change_free.set
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important state_change_pending.release
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 imap.gmail.com handler finished
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important state => LOGOUT
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important [sync] LOGOUT ()
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important state_change_pending.acquire
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important ["<class 'offlineimap.imaplib2.abort'>: connection closed"]
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important _close_threads
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important call shutdown
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important state_change_pending.release
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.13 Copy message from Remote:[Gmail]/Important connection closed
2015-10-24 20:16:50 DEBUG: [thread]: Register new thread 'Copy message from Remote:[Gmail]/Sent Mail' (account 'gmail')
2015-10-24 20:16:50 INFO: Copy message 26 (23 of 2426) Remote:[Gmail]/Sent Mail -> Local
2015-10-24 20:16:50 INFO: Establishing connection to imap.gmail.com:993
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.14 Copy message from Remote:[Gmail]/Sent Mail imaplib2 version 2.43
2015-10-24 20:16:50 DEBUG: [imap]:   16:50.14 Copy message from Remote:[Gmail]/Sent Mail imaplib2 debug level 5, buffer level 3
2015-10-24 20:16:50 WARNING: Thread 'Copy message from Remote:[Gmail]/Important' terminated with exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/offlineimap/threadutil.py", line 163, in run
    Thread.run(self)
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/Gmail.py", line 291, in copymessageto
    super(GmailFolder, self).copymessageto(uid, dstfolder, statusfolder, register)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 770, in copymessageto
    message = self.getmessage(uid)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/Gmail.py", line 77, in getmessage
    data = self._fetch_from_imap(imapobj, str(uid), 2)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 684, in _fetch_from_imap
    imapobj.select(self.getfullname(), readonly = True)
  File "/usr/lib/python2.7/site-packages/offlineimap/imaplibutil.py", line 50, in select
    result = super(UsefulIMAPMixIn, self).select(mailbox, readonly)
  File "/usr/lib/python2.7/site-packages/offlineimap/imaplib2.py", line 1008, in select
    typ, dat = rqb.get_response('command: %s => %%s' % rqb.name)
  File "/usr/lib/python2.7/site-packages/offlineimap/imaplib2.py", line 188, in get_response
    raise typ(exc_fmt % str(val))
OfflineImapError: Server 'imap.gmail.com' closed connection, error on SELECT '[Gmail]/Important'. Server said: command: EXAMINE => socket error: <class 'socket.error'> - [Errno 104] Connection reset by peer


Last 15 debug messages logged for Copy message from Remote:[Gmail]/Important prior to exception:
thread: Register new thread 'Copy message from Remote:[Gmail]/Important' (account 'gmail')
imap:   16:50.09 Copy message from Remote:[Gmail]/Important [sync] EXAMINE ('[Gmail]/Important',)
imap:   16:50.09 Copy message from Remote:[Gmail]/Important state_change_pending.acquire
imap:   16:50.09 Copy message from Remote:[Gmail]/Important _request_push(MNPA92, EXAMINE, {}) = MNPA92
imap:   16:50.10 Copy message from Remote:[Gmail]/Important data=MNPA92 EXAMINE "[Gmail]/Important"
imap:   16:50.10 Copy message from Remote:[Gmail]/Important EXAMINE:MNPA92.ready.wait
imap:   16:50.13 Copy message from Remote:[Gmail]/Important state_change_pending.release
imap:   16:50.13 Copy message from Remote:[Gmail]/Important state => LOGOUT
imap:   16:50.13 Copy message from Remote:[Gmail]/Important [sync] LOGOUT ()
imap:   16:50.13 Copy message from Remote:[Gmail]/Important state_change_pending.acquire
imap:   16:50.13 Copy message from Remote:[Gmail]/Important ["<class 'offlineimap.imaplib2.abort'>: connection closed"]
imap:   16:50.13 Copy message from Remote:[Gmail]/Important _close_threads
imap:   16:50.13 Copy message from Remote:[Gmail]/Important call shutdown
imap:   16:50.13 Copy message from Remote:[Gmail]/Important state_change_pending.release
imap:   16:50.13 Copy message from Remote:[Gmail]/Important connection closed
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/OfflineIMAP/offlineimap/issues/198#issuecomment-150842737">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AKFSEM0_zgNbb6GQ6GqupjG0_rvcTC1_ks5o-9Q5gaJpZM4EaYUs.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/OfflineIMAP/offlineimap/issues/198#issuecomment-150842737"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>