When you enable XML sitemaps, or change some options related to XML sitemaps, you have to flush your permalinks (ie: updating URL rewriting).
To do that, just click the Flush permalinks button in SEO > XML / HTML Sitemap.
Or, go to Settings > Permalinks. You don’t need the save the page to flush your permalinks. It’s done each time you visit this page.
Also, make sure to never cache XML sitemaps. Usually, caching plugin like W3Total Cache or WP Rocket automatically exclude this kind of files.
Finally, maintenance mode (via plugins for example) needs to be deactivated.
NGINX users must add to their nginx configuration file these rewrite rules:
Last modified: April 10, 2019