Report this

What is the reason for this report?

DigitalOcean App Platform with Django - 502 Error when sending DELETE requests via postman

Posted on November 5, 2023

Hi everyone. Ive been looking this up and cant find anything. Anytime I send a DELETE request via postman to my django backend hosted with the DigitalOcean app platform I get the error seen below. This is only for DELETE http requests. All others work perfectly fine. This app is linked to a DO managed postgreql db. I get absolutely no issues when running the backend locally and sending delete requests but any delete request sent to the deployed version gets this error. Help would be very appreciated. Thank you.

      <!DOCTYPE html>
      <html>
      <head>
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <meta name="robots" content="noindex">
          <style>body,html{height:100%;margin:0}body{display:flex;align-items:center;justify-content:center;flex-direction:column;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}p{text-align:center;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;color:#000;font-size:14px;margin-top:-50px}p.code{font-size:24px;font-weight:500;border-bottom:1px solid #e0e1e2;padding:0 20px 15px}p.text{margin:0}a,a:visited{color:#aaa}</style>
      </head>
      <body>
      <p class="code">
        Error
      </p>
      <p class="text">
        We encountered an error when trying to load your application and your page could not be served. Check the logs for your application in the App Platform dashboard.
      </p>
        <div style="display:none;">
          <h1>
    upstream_reset_before_response_started{protocol_error} (502 UPE)      </h1>
          <p data-translate="connection_timed_out">App Platform failed to forward this request to the application.</p>
      </div>
      </body>
      </html>
    


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

This is quite interesting, receiving a 502 error only for DELETE requests can be tricky to diagnose, essentially as all other requests are working as expected.

There are a few things that I could suggest:

  1. The error message suggests checking the logs for your application in the App Platform dashboard. These logs might provide more specific information about what’s causing the DELETE requests to fail.

  2. Ensure that your Django app is correctly configured to handle DELETE requests. This includes checking the views and URL routing in your Django app.

  3. Since you’re using a DigitalOcean Managed PostgreSQL database, verify that the database permissions allow DELETE operations. Restrictions at the database level might result in errors when the application attempts to execute such queries:

https://docs.digitalocean.com/products/databases/postgresql/how-to/modify-user-privileges/

  1. You mentioned it works locally, but it’s worth re-testing to ensure there’s no issue with the request itself. Pay attention to any headers or authentication tokens that might be different between your local environment and the production environment on DigitalOcean.

If you’re unable to resolve the issue through these steps, reaching out to DigitalOcean support with detailed information about your configuration and the error might provide more insight:

https://www.digitalocean.com/support/

Hope that helps!

- Bobby.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.