1

Why my ec2 instance always timeout in about 60 seconds when I access http or https? After about 60 seconds always return:

Network Error (tcp_error)

A communication error occurred: "Operation timed out" The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.

For assistance, contact your network support team.

and some times return:

Gateway Timeout

The gateway did not receive a timely response from the update server or application.

I use apache web server and PHP with max timeout. I dont use ELB/Load Balancer in my EC2, and I never create any ELB. I tried to find solution in internet but always found ELB setting.

2

According this article I just need to run the command below

/sbin/sysctl -w net.ipv4.tcp_keepalive_time=200 net.ipv4.tcp_keepalive_intvl=200 net.ipv4.tcp_keepalive_probes=5

I tried and not working, but after I edited /etc/sysctl.conf and add following code:

net.ipv4.tcp_keepalive_time=200
net.ipv4.tcp_keepalive_intvl=200
net.ipv4.tcp_keepalive_probes=5

Then I rebooted my instance, and now the timeout is longer.

| improve this answer | |
1

In your apache/vhost config you need to set the Timeout directive to the desired timeout value.

https://httpd.apache.org/docs/2.4/mod/core.html#timeout

Description: Amount of time the server will wait for certain events before failing a request
Syntax: TimeOut seconds
Default: TimeOut 60
Context: server config, virtual host

| improve this answer | |
  • 1
    I already set it, the error came from TCP not apache. – Muhammad Dyas Yaskur Jun 28 '19 at 9:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.