Nginx subdomain shows 502 Bad Gateway

System Information
  • Strapi Version: 4.10.1
  • Operating System: Ubuntu 20.04 LTS
  • Database: Postgres
  • Node Version: >=14.19.1 <=18.x.x
  • NPM Version: >=6.0.0
  • Yarn Version: Using npm, not yarn

Hi, I followed the guide on deploying to a DigitalOcean droplet thoroughly and can’t solve a 502 Bad Gateway error which is probably coming from the Nginx configuration. I have a droplet where I’m setting up server blocks to host a domain, and a subdomain, for which I’m currently having issues. I can run strapi start in production, with and without pm2, without any errors, but when I visit on any browser, I see the 502 error.

All I want to do is visit to see the default Strapi landing page, for the api and for accessing the admin dashboard

I also tried following the guide on Nginx proxying and use the Nginx config there for subdomains but it just doesn’t work. I only skipped the very end of that guide because I’m not interested in redirecting the landing page to the admin panel.

Can anyone from the Strapi team provide a working Nginx config for subdomains in DO droplets or point out what I might have done wrong? Thank you in advance.

1 Like

I’ve had the same issue. Would be great to get some help with this. @Pedro_Rodrigues Did you manage to solve this by any chance?

There was a problem with the Strapi app. I diagnosed the problem by running pm2 logs strapi --lines 20.

For me, it was that the environment variables were not set correctly. Problem solved and app now running with admin dashboard accessible in the remote hosted environment.