The Nginx process will often serve a 502 if the application raises an exception, an internal API call raises an exception or if the request simply takes too long. As such, the status code by itself does not tell us much.
Without knowing your logs and your code, it is hard to tell why you are not using the server ports. Please note that
port 3000 is used all the time and it is usually safe for development usage. I do not think this is the underlying issue.
I suggest checking the routing handlers of your app. Try calling the crashing endpoints and trace it to the dispatchers all the way to the actual function.