Accounts.createUser and Meteor.loginWithPassword throw 502 Bad Gateway

Hello, I have a problem in my meteor app. My app works fine in localhost, but when I deploy it, and try to create a user with Accounts.createUser or when I try to login with Meteor.loginWithPassword, browser console prints 502 bad gateway and the app breaks. I’ve also tried calling Accounts.createUser from the server methods and still the same. The app loads database fine, I’ve tried calling other methods, and they work fine, I can insert, update and remove anything from the db inside the browser console, and the only thing that’s not working is creating a user and logging in.

I’ve tried everything that came to my mind, changing the MUP config file, the protocol, changing the server port, nginx config, server firewall, and other stuff, but nothing has worked so far. And the wierd thing, is that I have another app, that uses the same DB, is on the same server, just different port and I deploy it in the same exact way.

Meteor version is 1.8.1

MUP is used for deployment.

Server is Ubuntu 18.04, nginx hosted on DigitalOcean.

MUP config file image:
502 error image: