Segev
Segev

Reputation: 19303

Network is unreachable if running script on webhosting

The next script runs fine on my mac. When I try to run it on my WebHosting (bluehost) I'm getting socket.error: [Errno 101] Network is unreachable. Any idea how can I fix it?

#!/usr/bin/python
# Required header that tells the browser how to render the text.
print "Content-type: text/html\r\n\r\n";

import imaplib
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('[email protected]', 'password')
mail.list()
# Out: list of "folders" aka labels in gmail.
mail.select("inbox") # connect to inbox.
print mail.list()


Traceback (most recent call last):
  File "test2.py", line 6, in <module>
    mail = imaplib.IMAP4_SSL('imap.gmail.com')
  File "/home4/user/python27/lib/python2.7/imaplib.py", line 1148, in __init__
    IMAP4.__init__(self, host, port)
  File "/home4/user/python27/lib/python2.7/imaplib.py", line 163, in __init__
    self.open(host, port)
  File "/home4/user/python27/lib/python2.7/imaplib.py", line 1159, in open
    self.sock = socket.create_connection((host, port))
  File "/home4/user/python27/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 101] Network is unreachable

Their support isn't helpful at all.

Can it be port related or maybe SSL?

Upvotes: 1

Views: 1955

Answers (1)

mata
mata

Reputation: 69062

On bluehosts help pages they mention that outgoing connnections are restricted, so ther problem isn't with your program. The only way of getting outbound connections to be allowed seems to pay for it.

Upvotes: 1

Related Questions