Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add a python script to a shared web hosting account and I cannot get even the most basic of scripts to establish a valid imap connection to gmail. Just as a test case, I created the following script:

import imaplib
conn = imaplib.IMAP4_SSL("", 993)

This produces the following ouput:

Traceback (most recent call last):
File "", line 2, in ? conn = imaplib.IMAP4_SSL("", 993) File "/usr/lib64/python2.4/", line 1101, in init IMAP4.init(self, host, port) File "/usr/lib64/python2.4/", line 160, in init, port) File "/usr/lib64/python2.4/", line 1113, in open self.sock.connect((host, port)) File "", line 1, in connect socket.error: (110, 'Connection timed out')

How would I go about troubleshooting this issue? Is it possible that my hosting provider is blocking outgoing imap requests?

share|improve this question
up vote 2 down vote accepted

TELNET is always a good general purpose TCP testing tool that's available out-of-the-box on most OS's.

Can you TELNET to, port 993, from the shell on your hosted box and get an open TCP connection? If not, I'd start talking to the host about whether or not they're blocking that traffic.


To test connectivity to an arbitrary TCP port with TELNET you need to specify the port number on the TELNET command like. For port 993, for example:

telnet 993

If you don't specify a port number the default port for TELNET, port 23, is assumed.

share|improve this answer
I tried to test the connection with telnet, but it isn't working. The output is as follows. Trying telnet: connect to address Connection timed out telnet: Unable to connect to remote host: Connection timed out That appears to be correct IP address, but the connection obviously isn't established. – sglantz Jul 16 '10 at 12:53
Sorry about the formatting in the above post. After more testing it appears that no telnet connection is working. I tried connecting to and I received the same output expect the IP address was – sglantz Jul 16 '10 at 13:09
I'm dropping on an edit re: thee comments. – Evan Anderson Jul 16 '10 at 13:13
Oops, sorry about that mistake. Still no connection with on port 993, but I can establish other connections on port 80. – sglantz Jul 16 '10 at 13:35
Sounds like your outbound connections are being filtered by something, then. – Evan Anderson Jul 16 '10 at 13:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.