502 Bad Gateway in Azure

The 502 Bad Gateway error is an HTTP status code that generally indicates a gateway server received a faulty response from another server. In relation to IronPDF, this error can occur when deployed to Azure.

In this article, you will find several suggestions for how to resolve this error in Azure.

1. Uncheck "Run from package file"

When deploying your application to Azure in Visual Studio, you will be presented with a Run from package file option. Ensure this is unchecked before deploying your application to Azure. You could also set WEBSITE_RUN_FROM_PACKAGE = 0 in your application settings.

For more information on running your application from a package file, take a look at Microsoft's official documentation.

2. Change the region

At times, the systems of certain Azure regions will update, causing conflicts with IronPDF. If possible, redeploy your application to another region.

3. Set to run in Single Process mode

In your code, add the following line of code to your application and redeploy:

Installation.SingleProcess = true;

By default, IronPDF runs as a multi-process software module, spawning a new process for whatever task it is given (whether it be rendering HTML, sending a URL request, etc.). This makes IronPDF fault-tolerant, but less likely to run properly on constrained environments. When setting the option above, IronPDF will run as a single process, which will reduce its fault tolerance, but will improve the likelihood the library will run properly in constrained environments.

Because of this "trade-off", we recommend trying the above two suggestions first before trying this one.

4. Containerize your application

To ensure no changes in the Azure system tamper with IronPDF, containerize your application with Docker.

You can learn more about how to containerize IronPDF with Docker by following this link.

Still not working?

If you have tried all of the suggestions above and your application is still throwing the 502 Bad Gateway error, contact us at support@ironsoftware.com.

To learn how to make a support request, follow this link, and to learn how to retrieve log files from Azure, follow this link.