Forecast.py SSL errors for NWS

38 views
Skip to first unread message

rud...@gmail.com

unread,
Aug 2, 2025, 9:03:26 PM8/2/25
to weewx-user
I have an older version of Weewx and as such, older versions of the plugins.  This post references the forecast.inc plugin version 3.2.14 but it might be helpful for later versions also.

My forecast.py plugin stopped working and my syslog showed this 

 forecast: NWSThread: NWS: downloading forecast from 'http://forecast.weather.gov/product.php?site=NWS&product=PFM&format=txt&issuedby=MLB'
Aug  2 20:22:15 weather weewx[1091]: forecast: NWSThread: NWS: failed attempt 1 to download NWS forecast: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>

This is what fixed it.  

I went to the forecast.py source in

/usr/share/weewx/user

added

import ssl

in the import section of the code and then added this in the 

def NWSDownloadForecast(foid, url=NWS_DEFAULT_PFM_URL, max_tries=3):

function

            ctx = ssl.create_default_context()
            ctx.check_hostname = False
            ctx.verify_mode = ssl.CERT_NONE
            response = urllib2.urlopen(u, context=ctx)
            """below is the original now commented out source line"""
            """response = urllib2.urlopen(u)"""

Now my forecast is working perfectly fine.

Bob
Reply all
Reply to author
Forward
0 new messages