It’s probably fair to think that if, for some reason, your site goes down for a few hours, and then comes back up, your Google rankings won’t be hurt (even if Googlebot arrives while your site is down).
But what if your site is down for much longer than that–for example, beyond a day or two?
Such a question was asked to Google’s John Muller during the English Google SEO Office-Hours from December 10, 2021 (at roughly the 4-minute, 13-second).
The participant described his situation:
“One of my clients' websites will be down for a week or for two weeks.”
After further describing his situation, the participant asked,
“But there shouldn't be any ranking loss, or there could be a minimum ranking loss that I could get? Something like that.”
Part of John Mueller’s response was:
“I don't think you'll be able to do it for that time, regardless of whatever you set up.”
Referring to the 503 unavailable code (which is one thing you can use if your site is down), John said:
“...after a couple of days, we think this is a permanent result code and we think your pages are just gone, and we will drop them from the index. And when the pages come back, we will crawl them again and we will try to index them again.”
“But it's essentially during that time, we will probably drop a lot of the pages from the website from our index. And there's a pretty good chance that it'll come back in a similar way, but it's not always guaranteed.
“So any time you have a longer outage, I'm thinking more than a couple of days, I would assume that at least temporarily you will have really strong fluctuations and it's going to take a little bit of time to get back in.”
“It's not impossible, because these things happen sometimes. But if there's anything that you can do to avoid this kind of outage, I will try to do that. And that could be something like setting up a static version of the website somewhere and just showing that to users for the time being.
“But especially if you're doing this in a planned way, I would try to find ways to reduce the outage to less than a day if at all possible.”
So, I think John gave a fairly comprehensive answer: if your website is down for more than a day or so, Google may drop its rankings. Here’s a related article: “We’re Doing a Site Move. Can We Lose Rankings We Might Never Recover?” Google Responds.