Server Error Issues (5xx) | Blue Frog Docs

Server Error Issues (5xx)

Diagnose and fix server-side errors causing website downtime and failures

Server Error Issues (5xx)

What This Means

5xx server errors indicate problems on the server side that prevent it from fulfilling requests. These errors can cause complete site outages or intermittent failures.

Impact

  • Complete site inaccessibility during outages
  • Lost revenue from failed transactions
  • SEO penalties from persistent errors
  • Damaged user trust from poor reliability
  • Broken tracking from failed page loads

Common 5xx Errors

Code Error Meaning
500 Internal Server Error Generic server failure
502 Bad Gateway Upstream server failure
503 Service Unavailable Server overloaded or maintenance
504 Gateway Timeout Upstream server timeout
520-530 Cloudflare Errors CDN-origin communication issues

How to Diagnose

Check Server Logs

Apache:

tail -f /var/log/apache2/error.log

Nginx:

tail -f /var/log/nginx/error.log

Application logs:

  • Node.js: PM2 logs, application logs
  • PHP: php-fpm logs, application error logs
  • Python: Application logs, gunicorn/uwsgi logs

Monitor Resources

# CPU and memory
top
htop

# Disk space
df -h

# Active connections
netstat -tuln | wc -l

General Fixes

500 Internal Server Error

Check:

  1. Application error logs
  2. Syntax errors in code
  3. Missing dependencies
  4. Permission issues

Fix:

# Check file permissions
chmod 644 /var/www/html/*.php
chmod 755 /var/www/html/

# Check PHP syntax
php -l script.php

502 Bad Gateway

Causes:

  • Backend server not running
  • Backend server overloaded
  • Timeout on backend response

Fix:

# Restart application server
sudo systemctl restart php-fpm
sudo systemctl restart gunicorn

# Increase timeout
# Nginx example:
proxy_read_timeout 300s;

503 Service Unavailable

Causes:

  • Server maintenance
  • Server overloaded
  • Rate limiting triggered

Fix:

  • Scale up server resources
  • Implement load balancing
  • Optimize slow endpoints
  • Enable caching

504 Gateway Timeout

Causes:

  • Slow database queries
  • Long-running scripts
  • Network issues to upstream

Fix:

# Increase timeout values
# Nginx:
proxy_read_timeout 120s;
proxy_connect_timeout 120s;

# PHP:
max_execution_time = 120

Prevention

1. Implement Monitoring

Set up alerts for:

  • Error rate thresholds
  • Response time increases
  • Server resource usage
  • Uptime checks

2. Auto-Scaling

Configure automatic scaling:

  • CPU-based scaling
  • Request-based scaling
  • Scheduled scaling for known traffic spikes

3. Load Balancing

Distribute traffic across servers:

  • Active-passive failover
  • Round-robin distribution
  • Health check-based routing

4. Graceful Degradation

Plan for partial failures:

  • Cached fallback pages
  • Queue long-running tasks
  • Circuit breakers for external services

Platform-Specific Guides

Platform Error Handling
Shopify Managed by Shopify
WordPress Check hosting/plugins
Squarespace Managed by Squarespace
Custom Full server access required
// SYS.FOOTER