Forums

SSH - Getting Connection Refused Port 22 for Paid Account

I'm trying to setup SSH tunneling so I can use MySQL Workbench -- this isn't working.

So when I check just basic SSH access i.e.

ssh myusername@ssh.pythonanywhere.com

I get port 22 connection refused error.

I read that this is a restriction on free accounts, but I've had a paid account since last year.

Any ideas?

I tried again later today and it's working now. Maybe it was just a problem on my computer.

Apologies for the false alarm. :-)

I have the same issue now. I have just switched to the hacker account and tried to log under a wrong username (and so 4 times entering the wrong password). Then I corrected the username but get "ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused". Was my IP blacklisted ?

yes- although the ban should lift in an hour. try again now?

I have the same problem but I think I didnt type anything wrong. I tried it from the console in the web and it worked, but from my computer comes the error message:

ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused Couldn't read packet: Connection reset by peer

Hope someone can help me

The connection reset message would not be a sign of wrong username/password and getting blocked.

Could you possibly be behind a firewall that is blocking ssh connections?

Could you also get more verbose logging for the problem? (eg: by doing a ssh -v)

Same issue. Waited for hours to try again and still the same. Turned off firewall at a MacBook.

ssh -v <username>@ssh.pythonanywhere.com

OpenSSH_7.6p1, LibreSSL 2.6.2

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 48: Applying options for *

debug1: Connecting to ssh.pythonanywhere.com port 22.

ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused

That look like your network is preventing the connection. The PythonAnywhere ssh server is fine and not refusing connections for your account.

Hello!! I need help too, I've tried to connect from my computer

ssh -L 3306:casalromina.mysql.pythonanywhere-services.com:3306 casalromina@ssh.pythonanywhere.com ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused

i dont have a paid account yet because im testing

Thanks!!

SSH access only works from paid accounts, unfortunately. If you're running some tests and considering upgrading if they work, you could just upgrade now -- we have a 30-day no-questions-asked money-back guarantee, so if the tests don't work out and you decide that you don't want a paid account within the first 30 days, you can just downgrade it to a free one then drop us a line, and we'll refund your payments.

Done! worked as expected Thanks

Excellent! Thanks for confirming :-)

Hi, I got the same error as below :
Failed to Connect to MySQL at bicsu.mysql.pythonanywhere-services.com:3306 through SSH tunnel at bicsu@ssh.pythonanywhere.com with user bicsu. IO Error: [Errno None] Unable to connect to port 22 on or 23.21.200.247. Please refer to logs for details.

I think my setting is right on the mysql workbench. Is there any problem on PA?

Are you able to to ssh in normally? (ie. instead of connecting to the MySQL database, can you ssh in to see your files etc)

@conrad,
Yap, I am using putty.
Especially, I can connect to MYSQL server by terminal.

What I want to do is that I want to send some result from my program. It will be 0 or 1. I want to send those result to webserver using mysql db from my local workstation to pythonanywhere web server. Do you think that this is possible? I should be processing in real-time.

Wait to clarify:

  1. you can use putty to accessing your pythonanywhere console
  2. you can connect to MySQL using ssh tunnelling?
  3. you are trying to do something with your PythonAnywhere database? Or something with a local database and then put it onto PythonAnywhere?

Sorry for my ambiguity.
1. No, I just use the putty to access from my laptop to the local server.
2. Yap. I can get MYSQL database on console using SSH tunneling in ubuntu terminal. I manipulated the database and checked it on console of PythonAnywhere.
3. What I am trying to do will be like as below:

a) I will create database on my local database file.
b) the database file should be sent to PythonAnywhere DB as soon as it is generated by python code.
c) I am going to connect DB on console with Django application to present something with that DB contents.

The reason why I am trying this connection is it is a lot of deep learning computation to get '3-a)' result. Therefore, I wanna use my local workstation GPU to get that result, and then send those results to web server to present something with html & CSS as soon as I get the result from my local.
I hope you understand what I am trying to do and will be very happy if you give me some advice.

gocha. Is this a normal sql db that you are using? or what is the format of the 3-a result? and if it's just a couple rows in a database, perhaps you shouldn't be trying to replace/connect two databases, but instead you could just write that row directly into the PythonAnywhere database?

3-a result will be a text file within like 25lines. Very light one.
I just solved this matter by using rsync with SSH, so I will send the text file from local to PythonAnywhere console while I am running my code on my workstation.
Thanks for thinking about this together though. :-P

nice! that sounds like the way to go.

Hi there, I have the same issue, and I don't know what I am doing wrong. I have a Web dev account, I am trying to use either Filezilla or the terminal, but doesn't work:

lab@domenico-HP-ENVY-Notebook:~$ sftp -v domi84@ssh.pythonanywhere.com
OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ssh.pythonanywhere.com [23.21.200.247] port 22.
debug1: connect to address 23.21.200.247 port 22: Connection refused
ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused
Couldn't read packet: Connection reset by peer

What am I doing wrong?

That sounds like something on your network or on your machine (like a firewall or an anti-virus) is blocking access to the outside world on port 22.

Thanks! It is the pi-hole (I don't know why). I disabled it and it works.

after few attempt to connect with wrong password:

ssh [username]@ssh.pythonanywhere.com -v OpenSSH_7.9p1, LibreSSL 2.7.3 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for * debug1: Connecting to ssh.pythonanywhere.com [23.21.200.247] port 22. debug1: connect to address 23.21.200.247 port 22: Connection refused ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused

anybody can help with that ?

changing ip has solve the problem

Yes, that would do it -- or you could wait for a while and try again. SSH servers on the public Internet get constantly hammered by hackers trying to get in; as a result, it's best practice to block an IP that makes repeated login attempts with the wrong password. We use a tool called fail2ban to do that; it simply monitors for incorrect logins, and if it sees a bunch coming from the same IP address, it blocks that IP for an hour. Once the hour is up, the IP is unblocked and you can try again.

Hi, I just faced this situation yesterday and today as well (it's so easy to mistype a name / copy wrong data in authorized_keys), and it took me such a long time to me to find the last answer! So, I just submitted a Pull Request on the help pages.

Ok. Thanks. I'll have a look at it.

Getting connection refused on first attempt to call ssh-copy-id

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: ERROR: ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused

Per this tutorial https://circleci.com/blog/automating-flask-deployments-with-pythonanywhere/?utm_source=google&utm_medium=sem&utm_campaign=sem-google-dg--uscan-en-dsa-maxConv-auth-brand&utm_term=g_-c__dsa&utm_content=&gclid=Cj0KCQjw2MWVBhCQARIsAIjbwoOV2JWCkoK6tfa4vd4PauhR66kwrLIWUzwelVQj47D8S-8uhTuMONYaAot4EALw_wcB

Amazing you haven't tried to make this experience at least a little less miserable in the literal years people have been complaining about it.

I am trying to follow the same as soak123 and I having the same issue. Any help?

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/matiaszulberti/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: ERROR: ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused

What is the exact command that you're using to start ssh-copy-id? I've checked our logs and I don't see any login attempts for your account username over the last few days.

Hello giles, thank you for replied. The command I ran was:

ssh-copy-id matiaszulberti@ssh.pythonanywhere.com

Hello giles, I wrote from my corp. account. But as I said before i tried with:

ssh-copy-id matiaszulberti@ssh.pythonanywhere.com

We're definitely not seeing any connection attempts with that username. What is the IP address that you're connecting from? Googling "whats my IP" will give the correct one.

I am trying to connect from CircleCI, I don't know how to get the ip address from there. Let me see.

I have followed this tutorial: link

I created the public/private key in the pythonanywhere console and then when I try to add my public key to the authorized_keys file and I run: ssh-copy-id matiaszulberti@ssh.pythonanywhere.com, I get the connection refuse error.

  • ssh-copy-id matiaszulberti@ssh.pythonanywhere.com
  • /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/matiaszulberti/.ssh/id_rsa.pub"
  • /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  • /usr/bin/ssh-copy-id: ERROR: ssh: connect to host ssh.pythonanywhere.com port 22: Connection refused

I don't understand what I doing wrong.

Ah, you're running the ssh-copy-id command on PythonAnywhere itself? In that case, what do you see if you run the hostname command in the same console?