Here is another PSA from Gary Illyes of Google. In short, if you serve a 4xx status code with your robots.txt file, then Google will ignore the rules you have specified in that file.
Why? Well, 4xx status codes means the document is not available, so Google won’t check it because the server says it is not available. Gary said this because he received a complaint or two about Google not respecting the robots.txt rules.
Gary wrote on LinkedIn, “PSA from my inbox: if you serve your robotstxt with a 403 HTTP status code, all rules in the file will be ignored by Googlebot. Client errors (4xx, except 429) mean unavailable robotstxt, as in, a 404 and a 403 are equivalent in this case.”
In short, make sure your robots.txt file serves a 200 status code and Google can access it.
Forum discussion at LinkedIn.