Chapter 10: Dynamic Website Hosting (PHP, Python, Node.js with MySQL)
10.7 Troubleshooting dynamic sites
| Symptom | Cause | Fix |
|---|---|---|
| 502 Bad Gateway | App not running; wrong port/socket; SELinux blocks proxy | sudo service flaskapp status/pm2 status; curl 127.0.0.1:3000; setsebool -P httpd_can_network_connect 1 |
| 504 Gateway Timeout | App too slow / stuck on DB | Check app logs; DB running? |
Access denied for user 'appuser' |
Wrong password or host (localhost vs 127.0.0.1) |
SELECT user,host FROM mysql.user; recreate user |
ECONNREFUSED ::1:3306 (Node) |
localhost resolved to IPv6 |
Use DB_HOST=127.0.0.1 |
Can't connect to MySQL server |
MariaDB/MySQL stopped | sudo service mariadb start (or mysql) |
cryptography package is required (Python) |
MySQL 8 auth needs it | pip install cryptography |
| PHP shown as text / downloaded | PHP handler missing | Install/start php-fpm; check location ~ \.php$ |
| Blank page / 500 in PHP | PHP error | sudo tail /var/log/php-fpm/www-error.log (AL/CentOS) or Nginx/Apache error log |
systemd service status=203/EXEC |
Wrong path in ExecStart, or SELinux blocking a binary in a home folder |
Check path; keep apps in /opt |