Resolving Error 521 via Server Logs

You're using Cloudflare to give yourselfWebsite AccelerationThis is a fairly common problem, so if you want to find out what's going on, just go toServer logsThe

Image [1]-Resolving Error 521 via Server Logs

What is Error 521?

Cloudflare has successfully contacted your server IP, but the server is not responding to it, as in "there's a knock at the door, but no answer inside". This is likely to be one of the following scenarios:

  • The server's Web services (e.g. Nginx (or Apache) is not running.
  • The firewall's blocking Cloudflare's IP.
  • The port's not open.
  • There was a configuration error that caused the request to be rejected outright

Let's see how the log helps you unravel the mystery step by step.

Step 1: Determine which environment you're running the site in

This is critical. Log locations vary from environment to environment.

  • If you're using a pagoda panel, the logs can be found on the site administration page
Image [2]-Resolving Error 521 via Server Logs
  • If you have a VPS and build your own Nginx or Apache, the logs are generally in the /var/log/nginx/ maybe /var/log/apache2/
  • If you are using a web host, you may have to log into your control panel and look for an entry like "Error Logs" or "Raw Logs".
Image [3]-Resolving Error 521 via Server Logs

In short, figure out your Web services software and system architecture to find the logs successfully.

Step 2: Look at the access log access.log

This log records "who visited your site" and "the results of the visit".

Image [4]-Resolving Error 521 via Server Logs

You can view the last few minutes of requests with the command:

tail -n 100 /var/log/nginx/access.log

If you find that Cloudflare's IP made the request, but the server returned the 502, 499 or just no response, then the request arrived but was not processed.

Step 3: Focus on the error log error.log

That's the whole point of troubleshooting Error 521.

Look at the order:

tail -n 100 /var/log/nginx/error.log

You may see something similar:

[error] 12345#0: *67 connect() failed (111: Connection refused) while connecting to upstream

See this "Connection refused"? That's the root cause of why the server is ignoring Cloudflare.

Or there's this:

[crit] 23456#0: *89 SSL_do_handshake() failed

This could be SSL SettingsThere is a problem, there is no HTTPS connection between Cloudflare and the server.

Step 4: Look for clues against time points

You can't go through everything from a huge pile of logs. So here's what you're going to do:

  1. Make a note of the approximate time when Error 521 occurs.
  2. Go to the log and search for records near that point in time.
  3. Look for particularly frequent requests, abnormal status codes, restart logs, etc.

At this point if you see a plugin requesting too often and a port reporting an error, that basically locks down the scope of the problem.

Step 5: Firewalls and ports check too!

Don't just stare at the logs, sometimes it's the server that's blocking Cloudflare's IP. you can look at yourfirewallsSetting:sudo ufw status

Or:iptables -L

Verify that 80 and 443 are open, and make sure that Cloudflare's IP segments are not blocked.

Image [5]-Resolving Error 521 via Server Logs

The official Cloudflare documentation has a list of all IP segments and recommends whitelisting them all.

Image [6]-Resolving Error 521 via Server Logs

Step 6: Try restarting the web service.

Sometimes a web service suddenly hangs, and a simple trick can fix it:

sudo systemctl restart nginx

Or use Apache:

sudo systemctl restart apache2

Reboot and then look at the logs for any new hints.

Step 7: Turn on more detailed logging (optional)

If you can't see the problem in the normal logs, you can temporarily increase the log level, for example, set the log level of nginx to debug, reproduce the access exception again, and then come back to look at the logs, and you'll probably be able to see the key clues.

Of course, remember to change it back after debugging, or the logs will take up crazy amounts of hard disk space.

summarize

tackle Error 521 The core of this is to figure out what server you are using, find access.log and error.log, lock the point in time when the problem occurs, and then follow the information down a little bit. With restarting services, checking firewalls, and whitelisting settings, you can basically get it done.


Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
Customer Service
Customer Service
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
This article was written by Little Lin
THE END
If you like it, support it.
kudos1489 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments