スキップしてコンテンツを表示

Lightsail instance starts and connects normally, but then connection fails after a period of time

0

I have a Lightsail instance that I can connect to. However after some time or periods of inactivity, the connection fails. I then have to close the current instance and connect to. new instance. My CPU usage has never gone into the burstable zone, and my networking connections have been assigned correctly: SSH --> port 22, HTTP --> port 80, HTTPS --> 443. Once I connect to the instance, I would like it to remain running indefinitely.

  • after some time or periods of inactivity, the connection fails

    Can you describe in more detail what it means for the connection to fail? Does the terminal appear connected? Do keyboard inputs show up? Do you see a modal/overlay prompting you to reconnect?

    I then have to close the current instance and connect to new instance

    Does this mean you close the Lightsail connect window and open a new connection or do you need to re-create the instance?

    Once I connect to the instance, I would like it to remain running indefinitely.

    Terminal connections are expected to timeout after a few hours of inactivity. If you have a long-running process you want to monitor you may want to install/use a tool like tmux that can create and resume sessions after an SSH session ends. A third-party shell like Terminal on Mac OS or PuTTY on Windows can also maintain longer sessions.

質問済み 5ヶ月前45ビュー
1回答
0

This is a common issue with Lightsail instances that can have several causes. Based on your description, here are some potential causes and solutions:

  1. Resource Utilization: Even though you mentioned your CPU usage hasn't gone into the burstable zone, it's worth checking other resource metrics like memory usage. High memory consumption can cause an instance to become unresponsive even when CPU usage appears normal.

  2. OS-level Issues: The problem might be occurring at the operating system level. When you can access the instance, check the system logs for any errors or warnings that might indicate what's causing the connection failures.

  3. Firewall Settings: An OS-level firewall might be automatically blocking SSH connections after periods of inactivity. When you regain access, you could try running commands to disable the firewall or reset iptables:

sudo ufw disable
sudo iptables -F
sudo mv /etc/hosts.deny /etc/hosts.deny_backup
sudo touch /etc/hosts.deny
sudo systemctl enable sshd
sudo systemctl restart sshd
  1. Instance Size: If your workload is consistently demanding more resources than your current plan provides, consider upgrading to a larger Lightsail plan. Remember that for some Lightsail plans, 20% CPU usage is the baseline throughput, so even if you're not hitting the burst capacity, you might still be experiencing resource constraints.

  2. Automatic Reboot Solution: While not ideal as a permanent solution, you could set up a system to automatically reboot your instance when it becomes unresponsive.

When you can access the instance, I recommend monitoring system resources closely and checking logs to identify patterns that might help diagnose the root cause. The goal should be to address the underlying issue rather than relying on frequent reconnections or reboots.
Sources
Lightsail instance keeps timing out | AWS re:Post
Lightsail SSH connect timing out | AWS re:Post
AWS lightsail need reboot every ten hours | AWS re:Post

回答済み 5ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ