0

I am running a PHP server from an AWS EC2 instance. It seems whenever I close my laptop (which is running a terminal session to the EC2 instance), the EC2 instance goes into sleep mode, and all incoming http requests from remote clients fail.

This is an T2.micro EC2 instance. And Hibernation is not enabled.

What should I do to keep the EC2 instance from going to sleep?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
yorkville
  • 13
  • 5
  • Amazon EC2 instances do not "go to sleep". What do you mean by "incoming http requests from remote clients fail"? Are you referring to requests that go to the PHP server on the EC2 instance? How did you start the PHP server -- from the command-line, or does it start automatically when the instance boots? Are you connecting to the EC2 instance via SSH or RDP? – John Rotenstein Jan 20 '22 at 23:56
  • The PHP server starts automatically when the instance boots. I am accessing it through the default terminal enabled by AWS Cloud9 (AWS CLI) when the EC instance is created. I have remote clients simply trying to access a PHP file stored on the PHP Server. Whenever I close my laptop, after a few minutes, remote clients' request time out. If I open my laptop, go to the terminal window (AWS CLI), the screen would say "connecting". Then the remote clients can access the PHP server again. – yorkville Jan 21 '22 at 00:30

1 Answers1

2

You appear to be using an EC2 instance is created with Cloud9.

The 'hibernation' is a feature of Cloud9, not EC2. Cloud9 is intended to be a development environment -- it is not intended for 'production' usage.

If you want a website to be running at all times, you should really use an EC2 instance that is not created by Cloud9.

However, you can disable the hibernation. See: Changing the auto-hibernate settings on a AWS Cloud9 EC2 Instance

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470