XLSX Export Times Out with 504 Gateway Time-Out

I’m currently using Metabase version 33.4. I’m also running this on Elastic Beanstalk With an RDS instance that was configured on Startup. I am connected to a SQL Server database for the query I am attempting to export. The table has quite a few records but when I filter down the recordset I am approximately pulling back 67,000 records. that is using one filter on one field.

When I attempt to export to XLSX format I end up getting a 504 Gateway timeout error. I have successfully exported out to CSV. when I do attempt to export to xlsx it ends up stressing out my machine so much that it goes from Green to Yellow to Red status in EB and then becomes unresponsive for a while until it regains consciousness in a few minutes.

I have read a handful of different posts about instance size or timeout settings. I have attempted the following fixes without success.

  1. Change the connection draining setting two connection draining enabled and drain time out a hundred and 20 seconds. (Goal to ensure that the load balancer would continue to stay connected even after 20 seconds.)
  2. Set up a new instance without a load balancer in front and Leverage The H2 database for configuration. (Goal is to remove the load balancer from the equation)
  3. change the instance size of the Metabase instance from a T3. small to an M4.Xlarge ( goal is trying to eliminate memory or CPU performance from the equation)

I did read many different posts trying to identify the underlying problem. 1 Post recommended adding some additional statements in Nginx to increase connection time before time out. I wasn’t exactly sure where to put these values as it didn’t look like they were environmental values to be added to EB.

I also was not able to find any place to disable the ability to use the Excel export so that my user would not how is the system by doing something that doesn’t seem to work. While telling them to only use CSV is a logical answer somebody eventually will attempt to export to Excel and break the system for 5 minutes until it regains consciousness.

Any thoughts would be much appreciated.


Hi @Slickrock22
Exporting as XLSX is much more demanding that CSV, so that’s why it’s taking longer time and puts status in red.
The EBS version of Metabase comes with a built-in Nginx reverse-proxy, so if that’s what is returning the 504 error, then we have to look at that, but it might come from another place?
When you go through the website one-click, it tells Amazon to use the configuration from this file:
You can modify the configuration in that file and then manually upload it on the EBS setup page.
From what I can see, if the environment variable NGINX_FORCE_SSL is defined, then it uses a configuration, which should have 600 seconds timeouts, otherwise it uses the default, which is only 60 seconds - I don’t understand why there’s different configurations.
The extended timeouts was add in 0.33.2 by this PR:

@flamber thanks for the quick response. Totally understand on the XLSX being more demanding. I think that if the feature cant be delivered consistently that you should be able to disable. This will cause too much grief with non-technical end-users who just expect things to work. I checked the config file and it has #NGINX_FORCE_SSL: 1 in the 01_metabase.config file. Does that mean I am at 600 seconds? Looks like maybe this is schedule for 0.34.x?

The change is merged into 0.33.2.
You need to access the EBS console (if that’s even possible) to see what the Nginx configuration is defined as. I don’t use AWS, so I don’t know.
You still haven’t reported what is returning the 504 error, so it’s difficult to know where the chain jumps off the tracks.
Check the returned request headers in your browser developer Network-tab.

When there’s a hash (#) as the first character, then the line is ignored.
Looks like you need to modify 01_metabase.config to add the environment variable - like this:

                NGINX_FORCE_SSL: 1
        command: ".ebextensions/metabase_config/metabase-setup.sh server_https"
        ignoreErrors: true

Otherwise just modify metabase-setup.sh to match the Nginx configuration you want.