0

After connecting succesfully to AWS on the latest iMac through Bash Script 1:

chmod 400 ~/PEM.pem

ssh -i "~/PEM.pem" ec2-user@address.com

jupyter notebook --no-browser --port=8888

Then opening a new bash script and entering in Bash Script 2:

ssh -i "~/PEM.pem" -L 8000:localhost:8888 ec2-user@address.com

Both the Ec2 commands and Python script (on localhost:8000 opened in Chrome) all work fine for about 30 minutes, then all of a sudden I get the error on the second bash script:

channel 3: open failed: connect failed: Connection refused

This message then repeats when I try to reconnect to localhost:8000 in Chrome, which I am not able to do. I've tried replacing localhost with 127.0.0.1, but have not been succesful.

Would anyone understand what the problem is, and how to possibly fix this? The objective is to use Python through EC2, which I have done successfully many times on other computers, but am now having problems.

  • 1
    Once the tunnel fails, are there any problems creating a new tunnel? Are there any services that need to be restarted on the server? The error message may need some context... and some information from the server's side. – RubberStamp Dec 24 '18 at 14:13
  • When the tunnel fails, I can connect again with ssh, but then as soon as I go to localhost in the browser, the error appears again. – user5316628 Dec 24 '18 at 14:36
  • Maybe the problem stems because an ssh tunnel is not the ideal solution for that. – Rui F Ribeiro Dec 24 '18 at 16:18
  • 1
    Try -o ServerAliveInterval=10 – user1133275 Dec 24 '18 at 16:36
  • autossh? – user1794469 Jan 18 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.