google-colaboratory jupyter-notebook python python-3.x

Google colab file download failed to fetch error

I used google colab to make a dictionary, dump it into a json file and download the file into my laptop by this code:

from google.colab import files
import json
dict = {'apple': 'fruit', 'mango': 'fruit', 'carrot': 'vegetable', 'brocoli': 'vegetable', 'cat': 'animal'}
with open('sampleDictionary.json', 'w') as f:
json.dump(dict, f)'sampleDictionary.json')

When I try to run this code, it gives this error:

MessageError                              Traceback (most recent call last)
<ipython-input-29-1251d71a0a36> in <module>()
7 json.dump(dict, f)
----> 9'sampleDictionary.json')
10 f.close()
/usr/local/lib/python3.6/dist-packages/google/colab/ in download(filename)
176 'port': port,
177 'path': _os.path.abspath(filename),
--> 178 'name': _os.path.basename(filename),
179 })
/usr/local/lib/python3.6/dist-packages/google/colab/output/ in eval_js(script, ignore_result)
37 if ignore_result:
38 return
---> 39 return _message.read_reply_from_input(request_id)
/usr/local/lib/python3.6/dist-packages/google/colab/ in read_reply_from_input(message_id, timeout_sec)
104 reply.get('colab_msg_id') == message_id):
105 if 'error' in reply:
--> 106 raise MessageError(reply['error'])
107 return reply.get('data', None)
MessageError: TypeError: Failed to fetch

Click here to see the screenshot of my code and the error

Please help me out

you need to enable third-party cookies but for now it only works for Chrome browser, open


make sure the option for Block third-party cookies is disabled and click add button in Allow section then add