Troubleshooting Guide
Comprehensive troubleshooting guide for common issues in the Klinik Gunung Health Screening System
Troubleshooting Guide
This guide provides solutions to common issues and problems that may occur during development, deployment, and usage of the Klinik Gunung Health Screening System.
Table of Contents
- Backend Issues
- Frontend Issues
- Database Issues
- Authentication Issues
- Deployment Issues
- Performance Issues
- Network and Connectivity
- File Upload Issues
Backend Issues
Laravel Application Not Loading
Symptoms:
- 500 Internal Server Error
- White screen of death
- Application timeout
Solutions:
- Check Laravel Logs
tail -f storage/logs/laravel.log - Verify Environment Configuration
php artisan config:cache php artisan config:clear - Check File Permissions
chown -R www-data:www-data storage/ chown -R www-data:www-data bootstrap/cache/ chmod -R 775 storage/ chmod -R 775 bootstrap/cache/ - Verify PHP Extensions
php -m | grep -E "(curl|gd|mbstring|xml|zip)"
API Endpoints Returning 404
Symptoms:
- API routes not found
- 404 errors on valid endpoints
Solutions:
- Clear Route Cache
php artisan route:clear php artisan route:cache - Check Route Registration
Verify routes are properly registered in
routes/api.php - Verify API Prefix
Ensure requests include the correct prefix:
/api/v1/
Database Connection Issues
Symptoms:
- "Database connection refused"
- PDO connection errors
- Migration failures
Solutions:
- Check Database Credentials
Verify
.envfile has correct database settings - Test Database Connection
php artisan tinker DB::connection()->getPdo(); - Restart Database Service
sudo systemctl restart mysql # or sudo systemctl restart postgresql
Frontend Issues
Next.js Build Failures
Symptoms:
- Build process fails
- TypeScript compilation errors
- Module resolution issues
Solutions:
- Clear Cache and Dependencies
rm -rf node_modules .next npm install - Check TypeScript Configuration
Verify
tsconfig.jsonandnext.config.jsare properly configured - Update Dependencies
npm update
React Query Not Working
Symptoms:
- Data not loading from API
- Cache issues
- Stale data problems
Solutions:
- Verify API Base URL
Check
NEXT_PUBLIC_API_URLenvironment variable - Clear React Query Cache
import { useQueryClient } from '@tanstack/react-query' const queryClient = useQueryClient() queryClient.clear() - Check Network Tab Use browser dev tools to inspect API requests
Authentication Not Working
Symptoms:
- Login fails
- Protected routes accessible without login
- Token expiration issues
Solutions:
- Verify JWT Configuration
Check
config/jwt.phpand.envsettings - Clear Authentication Cache
php artisan config:clear - Check Token Storage Verify tokens are properly stored in localStorage
Database Issues
Migration Errors
Symptoms:
- Migration fails to run
- Foreign key constraint errors
- Table already exists
Solutions:
- Reset Migrations
php artisan migrate:reset php artisan migrate - Check Migration Order Ensure migrations are properly ordered by timestamp
- Manual Database Check
SHOW TABLES; DESCRIBE table_name;
Data Integrity Issues
Symptoms:
- Inconsistent data
- Foreign key violations
- Missing relationships
Solutions:
- Run Database Seeder
php artisan db:seed - Check Data Consistency
php artisan tinker // Run data validation checks - Backup and Restore
php artisan backup:run
Authentication Issues
Password Reset Not Working
Symptoms:
- Password reset emails not sent
- Invalid reset tokens
Solutions:
- Check Mail Configuration
Verify
.envmail settings - Test Email Sending
php artisan tinker Mail::raw('Test email', function($msg) { $msg->to('test@example.com')->subject('Test'); }); - Clear Cache
php artisan config:clear php artisan cache:clear
Role-Based Access Issues
Symptoms:
- Users can't access authorized features
- Incorrect permissions
Solutions:
- Verify User Roles
php artisan tinker $user = User::find(1); dd($user->role); - Check Middleware Verify role middleware is properly applied
- Clear Permission Cache
php artisan permission:cache-reset
Deployment Issues
Application Not Accessible
Symptoms:
- 502 Bad Gateway
- Connection refused
- Timeout errors
Solutions:
- Check Web Server Configuration
sudo nginx -t sudo systemctl status nginx - Verify PHP-FPM
sudo systemctl status php8.1-fpm - Check Application Logs
tail -f /var/log/nginx/error.log tail -f storage/logs/laravel.log
SSL Certificate Issues
Symptoms:
- HTTPS not working
- Certificate errors
Solutions:
- Check Certificate Installation
certbot certificates - Renew Certificate
certbot renew - Verify SSL Configuration Check nginx/ssl configuration
Performance Issues
Slow Page Loads
Symptoms:
- Slow initial page load
- High server response time
Solutions:
- Enable Caching
php artisan config:cache php artisan route:cache php artisan view:cache - Optimize Database Queries Add database indexes and optimize queries
- Check Server Resources
htop df -h
Memory Issues
Symptoms:
- Out of memory errors
- Application crashes
Solutions:
- Increase PHP Memory Limit
php -i | grep memory_limit # Update php.ini if needed - Optimize Images and Assets Use proper image formats and compression
- Check for Memory Leaks
Monitor memory usage with tools like
valgrind
Network and Connectivity
CORS Issues
Symptoms:
- Cross-origin request blocked
- Preflight request failures
Solutions:
- Check CORS Configuration
Verify CORS settings in
config/cors.php - Update Allowed Origins
'allowed_origins' => ['https://yourdomain.com'], - Check Request Headers Ensure proper headers are sent from frontend
Cloudflare Tunnel Issues
Symptoms:
- Tunnel not connecting
- DNS resolution failures
Solutions:
- Check Tunnel Status
cloudflared tunnel list - Restart Tunnel Service
sudo systemctl restart cloudflared - Verify DNS Configuration Check Cloudflare DNS settings
File Upload Issues
Upload Failures
Symptoms:
- Files not uploading
- Size limit exceeded
- Invalid file types
Solutions:
- Check File Permissions
chmod 755 storage/ chmod 755 storage/app/public/ - Verify PHP Upload Settings
php -i | grep upload - Check Storage Link
php artisan storage:link
Image Display Issues
Symptoms:
- Images not showing
- Broken image links
Solutions:
- Verify Storage Link
ls -la public/storage - Check File Paths Ensure correct paths in database
- Clear Browser Cache Hard refresh or clear browser cache
Getting Help
If these solutions don't resolve your issue:
- Check Application Logs
tail -f storage/logs/laravel.log tail -f ~/.npm/_logs/*.log - Enable Debug Mode
Set
APP_DEBUG=truein.env - Collect System Information
php --version node --version mysql --version - Contact Support
- Create an issue on GitHub
- Check existing issues
- Contact the development team
Preventive Measures
Regular Maintenance
- Update Dependencies
composer update npm update - Monitor Logs Set up log monitoring and alerts
- Backup Regularly
php artisan backup:run
Performance Monitoring
- Monitor Server Resources
Use tools like
htop,iotop,nmon - Database Optimization
php artisan db:monitor - Error Tracking Implement error tracking services
This troubleshooting guide is continuously updated. If you encounter an issue not covered here, please contribute by documenting the solution.