When your IP address displays the default NGINX welcome page but your domain points correctly to your website, this indicates a server configuration issue. This guide walks you through diagnosing and resolving the mismatch between IP-based and domain-based access to your web server.
How to Fix It
-
Step 1: Check NGINX Server Block Configuration
Verify that your NGINX server block (virtual host) is correctly configured to serve your website content. The server block should specify the correct document root and server name.
Open your NGINX configuration file (typically located at
/etc/nginx/sites-available/your-domain) and ensure it contains:server { listen 80; server_name yourdomain.com www.yourdomain.com; root /var/www/your-website; index index.html index.php; }If you want the IP address to also serve your website instead of the default NGINX page, add your server's IP address to the
server_namedirective or create a default server block. -
Step 2: Verify DNS Records
Confirm that your domain's DNS A record points to the correct IP address. Log into your DNS provider's control panel and check that the A record matches your server's IP address.
You can verify DNS resolution using:
dig yourdomain.com nslookup yourdomain.com -
Step 3: Wait for DNS Propagation
If you've recently made DNS changes, allow time for propagation across the internet. DNS changes typically take 1-24 hours to fully propagate, though they often complete within a few hours.
Check propagation status using online tools like whatsmydns.net to see how your DNS records appear globally.
-
Step 4: Clear Browser and DNS Cache
Your browser or local DNS resolver may be caching outdated records. Clear your browser cache and DNS cache to ensure you're seeing current results.
To flush DNS cache on different systems:
# Windows ipconfig /flushdns # macOS sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder # Linux sudo systemd-resolve --flush-cachesTry accessing your site in an incognito/private browsing window or a different browser to bypass cached data.
-
Step 5: Reload NGINX Configuration
After making any configuration changes, test and reload NGINX to apply them:
sudo nginx -t sudo systemctl reload nginxThe first command tests the configuration for syntax errors before applying changes.
Common Issues
- Default server block: If no server block matches the requested host (IP address), NGINX serves the first enabled site or the default server block. Configure a specific default_server block if needed.
- Multiple server blocks: Ensure only one server block listens on port 80 for your domain, or conflicts may occur.
- Firewall rules: Verify that your firewall allows HTTP (port 80) and HTTPS (port 443) traffic.
- Hosting provider limitations: Some hosting providers require specific configurations. Contact their support if issues persist after following these steps.