You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Map output from OSM returns blocked tiles, due to defective request or not following referer-policy #2236
I've been exploring the project recently and wanted to look into this issue as a way to get started. After looking into how referrerPolicy is handled, here is what I found:
Folium successfully passes Leaflet's referrerPolicy to the tile layer, so the package functionality is working as intended. However, the 403 Forbidden error from OpenStreetMap happens when the generated HTML map is opened directly from the local disk (file:// protocol), especially in browsers like Firefox.
In these cases, the browser security policy restricts or completely omits the standard HTTP Referer header for local files. Since OpenStreetMap's tile policy strictly requires a valid Referer, the server rejects the request.
It looks like this is a browser/origin limitation regarding local files rather than a rendering bug in Folium. For anyone encountering this, a reliable workaround is to serve the generated HTML file over a local HTTP server (for example, by running python -m http.server in the directory) or to use a tile source that doesn't enforce strict Referer checks.
Let me know if I missed anything or if there's any other way I can help!
This is a duplicate of #2215. As @Otavio-Novais notes, this is out of our control. This is caused by a combination of browser policies and OSM tile policy, neither of which are part of Folium.
Local HTML files opened via file:// by definition don't have a Referer header, and hence can't comply with the OpenStreetMap's Tile Usage policy requiring referers.
As an alternative, tile requests may set an X-Requested-With header (I confirmed this with the OSM Operations Working Group).
You'll need to include the leaflet-header plugin and set the header as part of the tile layer.
As an example, for GeoDesk's GOL Tool, this looks as follows:
Activity
Otavio-Novais commentedon Jun 10, 2026
Hi everyone!
I've been exploring the project recently and wanted to look into this issue as a way to get started. After looking into how referrerPolicy is handled, here is what I found:
Folium successfully passes Leaflet's referrerPolicy to the tile layer, so the package functionality is working as intended. However, the 403 Forbidden error from OpenStreetMap happens when the generated HTML map is opened directly from the local disk (file:// protocol), especially in browsers like Firefox.
In these cases, the browser security policy restricts or completely omits the standard HTTP Referer header for local files. Since OpenStreetMap's tile policy strictly requires a valid Referer, the server rejects the request.
It looks like this is a browser/origin limitation regarding local files rather than a rendering bug in Folium. For anyone encountering this, a reliable workaround is to serve the generated HTML file over a local HTTP server (for example, by running python -m http.server in the directory) or to use a tile source that doesn't enforce strict Referer checks.
Let me know if I missed anything or if there's any other way I can help!
hansthen commentedon Jun 11, 2026
This is a duplicate of #2215. As @Otavio-Novais notes, this is out of our control. This is caused by a combination of browser policies and OSM tile policy, neither of which are part of Folium.
clarisma commentedon Sep 2, 2026
Update
Corrected code below. The OSM tile servers are now accepting
X-Requested-Withheaders in lieu of aReferrer.We've encountered the same issue in GeoDesk.
Local HTML files opened via
file://by definition don't have aRefererheader, and hence can't comply with the OpenStreetMap's Tile Usage policy requiring referers.As an alternative, tile requests may set an
X-Requested-Withheader (I confirmed this with the OSM Operations Working Group).You'll need to include the
leaflet-headerplugin and set the header as part of the tile layer.As an example, for GeoDesk's GOL Tool, this looks as follows:
(Change
geodesk-gol/2.3.6to the Folium-specific identifier).hansthen commentedon Sep 3, 2026
@clarisma Thanks for investigating. I had some hope that it would work.
tonny62 commentedon Sep 16, 2026
If any one facing this issue in an application developed using Django, here's my fix.
viktortoenkoel commentedon Oct 7, 2026
Agreed that it's a clash between OSM and Local Browser Policy and that folium has nothing to do with it.
At the same time we folium users have even less chance to do anything.
Could someone with folium knowledge maybe look into if setting of "X-Requested-With" header would be possible ideally as a folium level parameter?
hansthen commentedon Oct 8, 2026
I see how this can be annoying. There is a user space fix that may work (not tested yet).
viktortoenkoel commentedon Oct 9, 2026
thank you, I can confirm that it works, I've ended up using this version: