Ravindra BagaleCourses & study guides

16. Live Project: Building a Reels App with EC2, S3 and RDS

16.12 Testing and Troubleshooting

Symptom Likely cause Check / fix
502 Bad Gateway PHP-FPM stopped or wrong socket sudo service php-​fpm status; ls /run/php-fpm/ (Ubuntu /run/php/)
Blank page / 500 PHP error sudo tail -​f /​var/​log/​php-​fpm/​www-​error.​log (Ubuntu: /​var/​log/​nginx/​error.​log)
413 Request Entity Too Large Nginx body limit client_​max_​body_​size 60M; then nginx -t and reload
"Upload failed (error code 1)" PHP upload_​max_​filesize too small Check 99-reels.ini, restart PHP-FPM
"Could not store the video" IAM role missing/wrong, wrong bucket or region Log shows AWS error code; aws sts get-​caller-​identity; policy resource videos/*
SQLSTATE[HY000] [2002] Can't reach RDS nc -​zv <endpoint> 3306; db-sg source = web-sg
SQLSTATE[HY000] [1045] Wrong DB user/password Test with mysql -​h ... -​u reels_​app -​p
Videos don't play, 403 in Network tab Presigned URL expired or signed for wrong region Reload page; aws_region must match the bucket
Videos blocked, CSP error in console media-src doesn't match the bucket host Put your exact bucket host in the CSP header
Login loops back to login page Secure cookie over HTTP, or session dir not writable Use HTTPS; ls -​ld /​var/​lib/​php/​session
sudo tail -f /var/log/nginx/access.log /var/log/nginx/error.log
sudo tail -f /var/log/php-fpm/www-error.log               # Amazon Linux 2023
curl -s -o /dev/null -w "%{http_code}\n" https://reels.yourdomain.com/feed.php   # 401 when logged out

Ravindra Bagale's Tip

Error aala ki students code badlayla lagtat. Aadhi log vacha! Bahutek vela uttar error.log madhech aste. Kram lakshat theva: browser DevTools (Network/Console) → Nginx error log → PHP-FPM log → AWS/RDS connectivity. Ha kram vaparla tar kontahi problem lavkar sapadto.

Practice task

Break the app on purpose three ways – stop PHP-FPM, detach the IAM role, remove the 3306 rule – and note the exact error and log line for each. Then fix them. This is exactly how you will think during incident response.