Forums

SHH Winerror 10060 for paid account

Hello, I need a bit of help! I've looked through the forums and there were not many posts on this. I'm not sure why but when running SSH on my local jupyter notebook, I'm unable to connect and keep getting an error.

I've tried using the basic code provided, just to determine a connection:

import sshtunnel

sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0

with sshtunnel.SSHTunnelForwarder(
    ('ssh.pythonanywhere.com'),
    ssh_username="jemm88",
    ssh_password="login_password",
    remote_bind_address=(jemm88.mysql.pythonanywhere-services.com', 3306)
) as server:
    print('Server connected via SSH')

I'm a paid account, made sure that my username was case sensitive, and I've managed to connect to the DB with DBeaver and MySQLBench and am able to read and write data, so I know it's unlikely due to a firewall issue.

The error message I get is:

2022-09-01 14:57:06,524| ERROR   | Could not connect to gateway ssh.pythonanywhere.com:22 : Unable to connect to ssh.pythonanywhere.com: [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
    BaseSSHTunnelForwarderError: Could not establish session to SSH gateway

The full code I was going to use, came from https://www.pythonanywhere.com/forums/topic/12295/, adjusted per comments to make it work.

import pandas as pd
from sqlalchemy import create_engine
import sshtunnel

sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0
host = '127.0.0.1'
user = 'myuser'
passwd = 'mycode'
db = 'myuser$dbname'

with sshtunnel.SSHTunnelForwarder(
    ('ssh.pythonanywhere.com'),
    ssh_username="pythonanywhere_username",
    ssh_password="pythonanywhere_passwd",
    remote_bind_address=('myuser.mysql.pythonanywhere-services.com', 3306)
) as server:
    print('Server connected via SSH')
    port = str(server.local_bind_port)
    conn_addr = 'mysql://' + user + ':' + passwd + '@' + host + ':' + port + '/' + db
    print("[SQL] Trying to connect to " + conn_addr)
    engine =create_engine(conn_addr, pool_recycle=280)
    print('[SQL] Connexion established on ' + conn_addr)
    dataDF = pd.read_sql('SHOW TABLES from myuser$dbname', engine)
    print(dataDF)

Are you able to simply ssh to your account, using putty or just from the command line?

Both using the normal cmd vs anaconda cmd, I'm not able to connect via ssh.

I'm assuming you mean this when connecting: ssh -v jemm88@jemm88.mysql.pythonanywhere-services.com

For anaconda cmd, my port 22 connection was aborted. For my local cmd, connection timed out.

What is "the normal command" and the "anaconda command"?

Your ssh command is not correct. The ssh server is ssh.pythonanywhere.com, not jemm88.mysql.pythonanywhere-services.com

Ahh opps sorry on that.

Yep! it then works with via the command line. The authentication was successful. It works now as well on my local jupyter notebook.

Not sure what changed but thanks!