Fix “Web Server Is Returning an Unknown Error” (HTTP 520/521)

Oh no! You open your website, and instead of happy visitors shopping or reading your blog, you see a weird error message. It says something like this: “Web Server Is Returning an Unknown Error”, or maybe you see numbers like HTTP 520 or 521. Yikes!

Don’t panic. These errors are kind of cryptic, but they’re not too tough to fix. Let’s walk through what’s going on, why it happens, and how to make it go away. We’ll keep it simple, we promise.

What Are HTTP 520 and 521 Errors?

  • 520 Error: This means your server returned something strange to the content delivery network (usually Cloudflare).
  • 521 Error: This means the webserver itself is down or is refusing connections.

If you’re using Cloudflare (or something similar), you might see these errors when you try to visit your site. Basically, Cloudflare tries to talk to your server — and your server either says something weird (520) or says nothing at all (521).

Why Do These Errors Happen?

Let’s look at some common culprits:

  • Firewall Problems: Your firewall may be blocking Cloudflare or other traffic.
  • Server is Down: Your origin server might actually not be running!
  • Bad Web Server Settings: The server is misconfigured or overloaded.
  • Bad Plugins or Scripts: If you’re using WordPress or similar tools, buggy plugins can crash things.

Now let’s get to the fun part—fixing it!

Step-by-Step Fix for HTTP 520

1. Check Your Server Logs

Go to your server dashboard (like cPanel or your VPS dashboard). Look for logs. These show what was happening when the error appeared. This can give you clues.

2. Restart the Web Server

Sometimes, the web server process needs a kick. If you use Apache or Nginx, simply restart it.

sudo service apache2 restart
sudo service nginx restart

If you’re using another stack, find out which service needs restarting. Boom, sometimes this alone is enough!

3. Disable Bad Plugins or Apps

If you use WordPress, try deactivating all plugins. Then enable them one by one.

  1. Rename the plugins folder to something like plugins-old.
  2. Visit your website (it should work now).
  3. Rename it back and activate plugins one by one.

4. Clear the Cache

Cloudflare and browsers love caching. But sometimes cache causes more trouble than help. Clear them all!

  • On Cloudflare: Go to the dashboard > Caching > Purge Everything.
  • On Browser: Clear your cache or try an incognito window.

5. Check .htaccess or Config Files

If your server has rules in the .htaccess file (Apache) or nginx.conf, one wrong line can cause errors.

Look out for:

  • Unusual rewrite rules
  • Blocked IP ranges
  • Redirect loops

If you’re not sure, rename the file and try without it temporarily.

6. Talk to Hosting Support

This one might seem like a cheat. But seriously, if you’re stuck, just ask your host. They can check server-level things you can’t access.

Step-by-Step Fix for HTTP 521

1. Check If the Server Is Up

Try to access your server directly via IP address. If you can’t reach it, then your server is really down 🙁

Check your host’s status page or contact support.

2. Whitelist Cloudflare IPs

Cloudflare has a list of IP addresses that need access to your server. If a firewall is blocking these, you’ll get 521 errors.

Here’s what to do:

  1. Go to your server’s firewall settings.
  2. Add Cloudflare’s IP ranges (available on their website).

This tells the firewall: “Hey, it’s cool, let Cloudflare in.”

3. Ensure Web Server Is Running

On your server, make sure Apache or Nginx is live and healthy. Use SSH to log in, and type this:

ps aux | grep apache
ps aux | grep nginx

If nothing shows up, your server’s web software isn’t running. Look at your memory usage too—if RAM is full, the server might have shut down processes.

4. SSL Certificates Can Break Things

If your server uses HTTPS, make sure your certificate hasn’t expired. Cloudflare also has SSL settings. Set it to the right mode (Flexible, Full, or Full Strict) based on what your server supports.

If it’s mismatched, Cloudflare might try to talk HTTPS to a server that’s not listening. That never ends well.

Extra Tips for Both Errors

Enable “Development Mode”

This bypasses Cloudflare’s caching and talks directly to your server. Use this for testing things in real-time.

Turn Off Plugins Like ModSecurity

Some security modules block legitimate requests. Try disabling them temporarily to test.

Monitor Server Health

Use tools like:

  • Pingdom
  • UptimeRobot
  • New Relic

They alert you if your server goes down so you can act fast, even before users complain.

When to Call in the Experts

If nothing’s working and you’re stressed out, don’t be afraid to contact:

  • Your hosting provider
  • Your IT team or web developer
  • Forums like StackOverflow or Reddit’s r/webhosting

Sometimes fresh eyes on the problem find something you missed.

How to Prevent These Errors in the Future

  • Keep Plugins Updated: Old code breaks things.
  • Monitor Traffic Spikes: Too many users at once? Upgrade your server capacity.
  • Have a Backup Plan: Always have site backup and snapshot features enabled.
  • Set Up Downtime Alerts: The earlier you know about an issue, the faster you can fix it.

Final Thoughts

520 and 521 errors can feel like monsters in the closet. But once you understand what they mean, they’re more like little mischievous imps messing with your server connection.

Be methodical. Don’t change five things at once. Try one fix, test your site, then move to the next. Before you know it, your website will be back and better than ever.

If you’re still seeing weird errors — take a coffee break, breathe, and come back fresh. Websites can be tricky, but you’ve got this!

Happy fixing!