Express serves my HTML/HTMX code when running localhost:3000. I upload the GitHub branch to a web service on Render, and it builds fine without issue.
In production, I’m telling express to use port 443. However, when navigating the website.onrender.com, all I get is a blank page with this error in the console:
“Failed to load resource: the server responded with a status of 502 (Bad Gateway)”.
This works perfectly locally, so I’m trying to understand where my issue could lie. I come from a MERN stack background, so this is my first time trying to serve HTML/HTMX with an express server in a live environment.
Render Web Services expect an HTTP server to start on 0.0.0.0 and a port (default 10000). TLS is handled upstream, so your server only needs to be setup to respond to HTTP calls (not HTTPS).
The port set on your server is only for communicating inside the Render network. Web Services are only accessible from the public internet on port 443 (HTTPS default).