Can't connect to Lightsail instance

1

I wanted to connect to my database remotely and did some modifications to allow this. Followed the instructions in the Connect To MariaDB From A Different Machine page. Hit a bump in the first step; the ufw command was not recognized. So I tried to find a way to install it and followed the instructions in the -bash: ufw: command not found (ubuntu 18.04) page.

I did all that and now I can't connect to my instance. The site in the instance is inaccessible. Can't connect using SSH or FTP. Can't ping the IP.

Restarting the services and/or the instance did not work. If I click on the "Connect using SSH" button in the instance page (in the Lightsail console) and wait long enough, I get the following error:

An error occurred and we were unable to connect or stay connected to your instance. If this instance has just started up, try again in a minute or two.

UPSTREAM_NOT_FOUND [519]

How can I regain access to my instance back? If the instance is not salvagable, is there a way to, well, salvage the database (and maybe the project files)?

akinuri
질문됨 2년 전1733회 조회
2개 답변
3
수락된 답변

Hi Akinuri,

Enabling ufw on a Lightsail instance can block you out of your instance. This has happened to me a while ago. You cannot ssh or connect to your instance through a browser-based ssh client. To recover my instance I took a snapshot of it since I did not create a backup on launch and created a new instance from it. You can use your backup if you have. When you launch the new instance via console add the following script as a launch script to disable ufw:

sudo service ufw stop

You can also use AWS CLI to launch the new instance from a snapshot by running the following command:

aws lightsail create-instances-from-snapshot --region <snapshot-region> --instance-snapshot-name <snapshot-name> --instance-names <new-instance-name> --availability-zone <preferred-AZ> --user-data 'sudo service ufw stop' --bundle-id <value>

Alternately, you can export your Lightsail snapshot to Amazon EC2 by following the steps here and here. Additionally, here is a video tutorial on how to export Lightsail instance to Amazon EC2 instance.

Hope this helps

Cebi
답변함 2년 전
profile picture
전문가
검토됨 9일 전
  • Hi. I tried creating a new instance from a snapshot (that is taken after the problem), but all I did was reboot the instance, which did not help. I tried the launch script approach twice, and it did not help, at first. Then I started looking into the EC2 approach. While doing that, I tried to connect to the instance (that run a launch script) again and it worked. I guess I had to wait some time. Exported the db and the files and moved to a new instance. So, thank you :)

  • Also, since the instance with lauch script worked while I was halfway with the EC2 approach, there were some snapshots, volumes, etc. in the EC2 console. I started a clean up; deleted an instance, an AMI, a volume, and a snapshot. Then I checked the Resources card in the Dashboard and I saw one in Security groups.

    There seems to a resource, VPC. I'm not familiar with this. Was this created with the "Export to Amazon EC2" task? Or was it always there (and somehow related to Lightsail)? I'm not sure if I should delete it.

0

Finally Figured out the issue, by creating another instance & was trying to replicate my issue that is: "ssh: connect to host x.x.x.x port 22: Operation timed out". on my lightsail instance.

Why I am unable to connect to the instance via SSH is that I did turn on the UFW in my ubuntu instance by typing sudo ufw enable, that is the main mistake I made, after doing this when I tried to connect my instance again via same steps, I was unable to connect.

The solution is, whenever we turn on the ufw, we must allow ufw with port 22, by running the command sudo ufw allow 22

parth
답변함 7달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠