You open your website.
Instead of the application, you see:
502 Bad Gateway
What does that actually mean?
In simple terms, something in front of your application tried to communicate with it but didn't receive a valid response.
The Application Might Still Be Running
A 502 doesn't automatically mean the server is offline.
Possible causes include:
- Application crashed
- Wrong port
- Application isn't listening
- Reverse proxy configuration
- Timeout
- Upstream service failure
That's why simply restarting everything isn't always the best first step.
Start With Logs
Look at the application logs.
If you see:
EADDRINUSE
that's one kind of problem.
If you see:
Database connection failed
that's another.
If you see:
Application started on port 3000
while the platform expects another port, that's yet another possibility.
Check the Port
A very common deployment issue is:
Platform expects: 8080
Application listens: 3000
The process can be alive while the platform cannot reach it.
Check the Application
Ask:
- Is the process running?
- Is it listening on the correct port?
- Is it returning HTTP responses?
- Is the database available?
- Did the latest deployment change anything?
Hostwares exposes deployment and runtime logs specifically for diagnosing these kinds of application failures.
Don't Fear the 502
A 502 is information.
It tells you that communication between infrastructure layers isn't working correctly.
Find which layer failed.
Fix that layer.
Don't treat every 502 as a server problem.