I recommend using the command line and WP CLI with the Gravity Forms add-on:
With that, you can delete entries, as shown here:
If you explain more about which entries you need to delete (are you just emptying trash, or deleting all entries, or something else?) we can help with a possible approach using the WP CLI. Thank you.
Another option might be to simply add a line to your php.ini file (or create one if you don’t already have one) and increase the PHP execution time. The php.ini file can go in your WP root, but it’s safer to keep it in your /wp-admin folder.
The line to add would be something like this:
max_execution_time = 30 (or make the value larger if that is what it’s already at or above)
You can read more about various fixes for a 502 error here:
Also, @michaeledi - I did work out the SQL commands for this, to empty the trash for a specific form. It does not handle deleting attachments, so if that is a concern, SQL is not the way to go, and the WP CLI for Gravity Forms is the way to go.
Once you get to the point that your list of entries/trash is empty for the specific form(s), you may want to look at the Form Connector extension’s Delete an Entry step. If you have time / business rules that determine if/when an entry can/should be deleted, as the last step in your workflow it can automate the deletion for you. Behind the scenes, the delete activity is hooked to a cron event and deleting the single entry involved so you would be very unlikely to encounter the 502’s you describe related to bulk deletions.