Search code examples
amazon-web-servicesamazon-elastic-beanstalk

Unable to increase the timeout on AWS Elastic Beanstalk


I'm trying to increase the timeout on Amazon Elastic Beanstalk but I still get a 504 Gateway timeout.

Here's what I've done so far:

.ebextensions/timeouts.config:

option_settings:
  - namespace: aws:elb:policies
    option_name: ConnectionSettingIdleTimeout
    value: 940
  - namespace: aws:elbv2:loadbalancer
    option_name: IdleTimeout
    value: 940

files:
  "/etc/nginx/conf.d/nginx.timeouts.conf":
      mode: "644"
      owner: "root"
      group: "root"
      content: |
        client_header_timeout   5;
        client_body_timeout     10;
        send_timeout            940;
        proxy_connect_timeout   2;
        proxy_read_timeout      940;
        proxy_send_timeout      10;

container_commands:
  01_update_nginx:
    command: "sudo sed -i 's/keepalive_timeout  65;/keepalive_timeout  940;/g' /etc/nginx/nginx.conf"
  02_restart_nginx:
    command: "sudo service nginx restart"

Procfile:

web: gunicorn --bind :8000 --workers 10 --timeout 935 --graceful-timeout 935 main:app

Despite this, I still get a "504 Gateway Time-out" after exactly 60.1 seconds.

What am I missing that should make it work?


Solution

  • Your /etc/nginx/conf.d/nginx.timeouts.conf does not work because this is a valid file for EB platforms based on Amazon Linux 1 (AL1). However, it as confirmed in the comments, you are using AL2.

    For AL2, the nginx settings should be in .platform/nginx/conf.d/, not in .ebextentions as shown in the docs in the "Reverse proxy configuration" section.

    Therefore, you could try creating the following .platform/nginx/conf.d/myconfig.conf file with the content of:

    client_header_timeout   5;
    client_body_timeout     10;
    send_timeout            940;
    proxy_connect_timeout   2;
    proxy_read_timeout      940;
    proxy_send_timeout      10;