Tengine 502 bad gateway with Java SpringBoot backend
2026-09-29
AdSense Slot
502 Bad Gateway means Tengine cannot connect to your SpringBoot backend.
Common reasons
- SpringBoot service not started
- SpringBoot listening on 127.0.0.1 only, Tengine cannot access
- Backend port mismatch in proxy_pass
- Backend crashed under heavy load
Debug step 1 Check SpringBoot status
sudo systemctl status springboot-app
Check if service running and listening port:
ss -tlnp | grep java
Debug step 2 Fix listening address
In application.properties of SpringBoot
server.address=0.0.0.0
server.port=8080
Tengine proxy config example
location /api {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
Step3 Check Tengine error log
tail -f /usr/local/tengine/logs/error.log
Error log will tell connection refused or timeout details.
Summary
Most 502 between Tengine and SpringBoot is network or service startup problem, not Tengine configuration bug.
AdSense Slot