Website Not Loading: Complete Troubleshooting Guide for Web Service Issues
Learn how to systematically troubleshoot website loading issues. Master DNS, network, web server, and application layer debugging techniques.
Website Not Loading: Complete Troubleshooting Guide for Web Service Issues
Website loading issues can stem from multiple layers of the technology stack, making systematic troubleshooting essential. A website that doesn't load could be caused by DNS problems, network connectivity issues, web server failures, application errors, or infrastructure problems. Understanding how to methodically investigate each layer helps quickly identify and resolve the root cause.
Understanding Web Service Architecture
Why Websites Fail to Load
Website loading failures can occur at multiple levels:
- DNS resolution - Domain name cannot be resolved to IP address
- Network connectivity - Server is unreachable or ports are blocked
- Web server issues - Service is down or misconfigured
- Application problems - Backend services are failing
- Infrastructure issues - System resources exhausted or misconfigured
Troubleshooting Methodology
A systematic approach to web service troubleshooting:
- External checks - Verify if the issue affects everyone or just you
- DNS resolution - Verify domain name resolution
- Network connectivity - Check server reachability and port accessibility
- Web server status - Verify service is running and listening
- Application layer - Check application processes and logs
- Infrastructure - Verify system resources and configuration
Step-by-Step Investigation
1. External Availability Check
Is the Site Down for Everyone or Just You?
# Check from your system
curl -I https://yourdomain.com
ping yourdomain.com
# Check from external services
# Use https://downforeveryoneorjustme.com
# Or check with multiple external tools
External Monitoring
# Check from different locations
curl -I https://yourdomain.com
curl -I https://yourdomain.com --resolve yourdomain.com:443:IP_ADDRESS
# Test from different networks
# Use mobile hotspot, different ISP, etc.
2. DNS Resolution
Check Domain Resolution
# Check if domain resolves
dig yourdomain.com
nslookup yourdomain.com
# Check DNS servers
cat /etc/resolv.conf
# Test with different DNS servers
nslookup yourdomain.com 8.8.8.8
nslookup yourdomain.com 1.1.1.1
DNS Troubleshooting
# Check DNS resolution with verbose output
dig +trace yourdomain.com
# Check specific record types
dig A yourdomain.com
dig AAAA yourdomain.com
dig MX yourdomain.com
# Check DNS propagation
dig @8.8.8.8 yourdomain.com
dig @1.1.1.1 yourdomain.com
3. Domain Routing Verification
Check if Domain Routes to Correct Server
# Compare domain resolution with server IP
curl -v https://yourdomain.com
# Check if domain resolves to expected IP
dig yourdomain.com | grep "IN A"
Load Balancer and CDN Checks
# Check load balancer configuration
# Verify DNS records point to correct load balancer
# Check CDN rules and cache settings
# Test direct server access
curl -I http://SERVER_IP
curl -I https://SERVER_IP
4. Network and Firewall Check
Port Accessibility
# Check if ports are open
telnet yourdomain.com 443
nc -zv yourdomain.com 80
nc -zv yourdomain.com 443
# Check routing
traceroute yourdomain.com
mtr yourdomain.com
Cloud Security Groups
# Check security groups (AWS)
aws ec2 describe-security-groups --group-ids sg-xxxxxxxxx
# Check firewall rules
iptables -L
ufw status
firewall-cmd --list-all
5. Web Server Status
Service Status Checks
# Check if web server is running
sudo systemctl status nginx
sudo systemctl status apache2
sudo systemctl status httpd
# Check if port is listening
netstat -tuln | grep :80
netstat -tuln | grep :443
ss -tuln | grep :80
ss -tuln | grep :443
Web Server Restart
# If web server is down, restart it
sudo systemctl restart nginx
sudo systemctl restart apache2
sudo systemctl restart httpd
# Enable and start service
sudo systemctl enable nginx
sudo systemctl start nginx
6. Application Logs
Check Web Server Logs
# Check web server logs for errors
tail -f /var/log/nginx/error.log
tail -f /var/log/nginx/access.log
tail -f /var/log/httpd/error_log
tail -f /var/log/httpd/access_log
# Check system logs
journalctl -u nginx -f
journalctl -u apache2 -f
journalctl -u httpd -f
Application-Specific Logs
# Check application logs
tail -f /var/log/app.log
tail -f /var/log/application.log
tail -f /var/log/stderr
# Check for crash reports
dmesg | grep -i error
journalctl -p err
7. System Resources
Check Disk, Memory, and CPU
# Check disk space
df -h
# Check memory usage
free -m
top
htop
# Check CPU usage
iostat -x 1
vmstat 1
Resource Monitoring
# Check for resource exhaustion
ps aux --sort=-%mem | head -10
ps aux --sort=-%cpu | head -10
# Check disk I/O
iotop
iostat -x 1
8. Backend Services
Check Database and Cache Services
# Check database status
systemctl status mysql
systemctl status postgresql
systemctl status mongodb
# Check cache services
systemctl status redis
systemctl status memcached
# Test database connectivity
mysql -h localhost -u username -p
psql -h localhost -U username -d database
Application Dependencies
# Check application server status
systemctl status tomcat
systemctl status node
systemctl status php-fpm
# Check for connection errors in logs
grep -i "connection" /var/log/app.log
grep -i "timeout" /var/log/app.log
9. SSL Certificate Issues
Check SSL Certificate
# Check SSL certificate
curl -Iv https://yourdomain.com
# Check certificate expiration
echo | openssl s_client -connect yourdomain.com:443 2>/dev/null | openssl x509 -noout -dates
# Test SSL configuration
sslscan yourdomain.com
testssl.sh yourdomain.com
SSL Troubleshooting
# Check for SSL certificate problems
openssl s_client -connect yourdomain.com:443 -servername yourdomain.com
# Check certificate chain
openssl s_client -connect yourdomain.com:443 -showcerts
10. Rollback and Recovery
Deployment Rollback
# If issue started after deployment, rollback
kubectl rollout undo deployment your-deployment
# Or redeploy previous version via CI/CD
git checkout previous-working-commit
./deploy.sh
Emergency Recovery
# Quick fixes for common issues
sudo systemctl restart nginx
sudo systemctl restart apache2
sudo systemctl restart httpd
# Clear caches
sudo systemctl flush-dns
sudo systemctl restart systemd-resolved
Comprehensive Troubleshooting Script
Automated Web Service Checker
#!/bin/bash
# web_service_checker.sh
# Configuration
DOMAIN="yourdomain.com"
LOG_FILE="/var/log/web_service_check.log"
ALERT_EMAIL="admin@company.com"
# Function to log actions
log_action() {
echo "[$(date)] $1" | tee -a "$LOG_FILE"
}
# Function to check external availability
check_external_availability() {
local domain="$1"
log_action "Checking external availability for $domain"
if curl -I "https://$domain" &>/dev/null; then
log_action "External availability: SUCCESS"
return 0
else
log_action "External availability: FAILED"
return 1
fi
}
# Function to check DNS resolution
check_dns() {
local domain="$1"
log_action "Checking DNS resolution for $domain"
if nslookup "$domain" &>/dev/null; then
log_action "DNS resolution: SUCCESS"
return 0
else
log_action "DNS resolution: FAILED"
return 1
fi
}
# Function to check network connectivity
check_network() {
local domain="$1"
log_action "Checking network connectivity to $domain"
if ping -c 1 "$domain" &>/dev/null; then
log_action "Network connectivity: SUCCESS"
return 0
else
log_action "Network connectivity: FAILED"
return 1
fi
}
# Function to check port accessibility
check_port() {
local domain="$1"
local port="$2"
log_action "Checking port $port accessibility on $domain"
if nc -zv "$domain" "$port" &>/dev/null; then
log_action "Port $port accessibility: SUCCESS"
return 0
else
log_action "Port $port accessibility: FAILED"
return 1
fi
}
# Function to check web server status
check_web_server() {
local service="$1"
log_action "Checking $service status"
if systemctl is-active --quiet "$service"; then
log_action "$service status: RUNNING"
return 0
else
log_action "$service status: STOPPED"
return 1
fi
}
# Function to check system resources
check_system_resources() {
log_action "Checking system resources"
# Check disk space
local disk_usage=$(df / | awk 'NR==2 {print $5}' | sed 's/%//')
if [ "$disk_usage" -gt 90 ]; then
log_action "WARNING: Disk usage is ${disk_usage}%"
return 1
fi
# Check memory usage
local memory_usage=$(free | awk 'NR==2{printf "%.0f", $3*100/$2}')
if [ "$memory_usage" -gt 90 ]; then
log_action "WARNING: Memory usage is ${memory_usage}%"
return 1
fi
log_action "System resources: OK"
return 0
}
# Function to send alert
send_alert() {
local subject="$1"
local message="$2"
echo "$message" | mail -s "$subject" "$ALERT_EMAIL"
log_action "ALERT SENT: $subject"
}
# Function to attempt fixes
attempt_fixes() {
local domain="$1"
log_action "Attempting to fix issues"
# Restart web server
if systemctl is-active --quiet nginx; then
log_action "Restarting nginx"
systemctl restart nginx
elif systemctl is-active --quiet apache2; then
log_action "Restarting apache2"
systemctl restart apache2
fi
# Flush DNS cache
log_action "Flushing DNS cache"
systemctl flush-dns 2>/dev/null || true
# Check firewall
log_action "Checking firewall rules"
ufw status | grep -E "(80|443)" || log_action "WARNING: HTTP/HTTPS ports may be blocked"
}
# Main troubleshooting function
main() {
log_action "Starting web service troubleshooting for $DOMAIN"
local issues_found=0
# Check external availability
if ! check_external_availability "$DOMAIN"; then
issues_found=$((issues_found + 1))
fi
# Check DNS resolution
if ! check_dns "$DOMAIN"; then
issues_found=$((issues_found + 1))
fi
# Check network connectivity
if ! check_network "$DOMAIN"; then
issues_found=$((issues_found + 1))
fi
# Check port accessibility
if ! check_port "$DOMAIN" "80"; then
issues_found=$((issues_found + 1))
fi
if ! check_port "$DOMAIN" "443"; then
issues_found=$((issues_found + 1))
fi
# Check web server status
if systemctl is-active --quiet nginx; then
if ! check_web_server "nginx"; then
issues_found=$((issues_found + 1))
fi
elif systemctl is-active --quiet apache2; then
if ! check_web_server "apache2"; then
issues_found=$((issues_found + 1))
fi
else
log_action "WARNING: No web server found running"
issues_found=$((issues_found + 1))
fi
# Check system resources
if ! check_system_resources; then
issues_found=$((issues_found + 1))
fi
# Attempt fixes if issues found
if [ "$issues_found" -gt 0 ]; then
log_action "Issues found: $issues_found"
attempt_fixes "$DOMAIN"
# Send alert
send_alert "Web Service Issues Detected" "Found $issues_found issues with $DOMAIN. Check logs for details."
else
log_action "All checks passed: Web service is healthy"
fi
log_action "Web service troubleshooting completed"
}
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--domain)
DOMAIN="$2"
shift 2
;;
--help)
echo "Usage: $0 [--domain DOMAIN]"
echo " --domain Domain to check (default: yourdomain.com)"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Run main function
main
Best Practices
1. Systematic Approach
# Always follow the same order
# 1. External availability
# 2. DNS
# 3. Network
# 4. Web Server
# 5. Application
# 6. Infrastructure
2. Log Analysis
# Check logs in chronological order
tail -f /var/log/nginx/error.log
tail -f /var/log/nginx/access.log
journalctl -u nginx -f
3. Configuration Validation
# Always test configuration before applying
nginx -t
apache2ctl configtest
4. Monitoring and Alerting
# Set up automated monitoring
*/5 * * * * /usr/local/bin/web_service_checker.sh --domain yourdomain.com
Common Pitfalls and Solutions
1. DNS Cache Issues
Problem: DNS changes not taking effect Solution: Flush DNS cache and wait for propagation
2. Firewall Blocking
Problem: Ports are blocked by firewall Solution: Check and configure firewall rules
3. SSL Certificate Issues
Problem: SSL certificate expired or misconfigured Solution: Check certificate validity and configuration
4. Resource Exhaustion
Problem: System resources exhausted Solution: Monitor and optimize resource usage
Conclusion
Website loading issues require systematic troubleshooting across multiple layers. By following a structured approach and using appropriate tools for each layer, you can quickly identify and resolve the root cause.
Key takeaways:
- Start with external checks - Verify if the issue affects everyone or just you
- Use appropriate tools - Different tools for different layers
- Check logs systematically - Error logs provide crucial information
- Validate configurations - Test before applying changes
- Monitor continuously - Set up automated monitoring and alerting