MP ConnectionError

Hi! Sorry to bother you, sir. I need to ask you guys for help, I haven’t been able to connect to the MP library for the last 2 to 3 weeks. Accessing MP data from the sample code or from pymatgen will result in the following connection error. My mp_api version is 0.45.2 which should be the latest version, how can this be solved?

Hey @weitengzhang1227, can you check your network connection / VPNs?

Also ensure you have your API key properly set as an environment variable (MP_API_KEY) and that it is recognized in your jupyter environment:

import os
print(os.environ.get("MP_API_KEY"))

If the environment variable isn’t recognized, you can always manually input the API key into MPRester like:

with MPRester(api_key = < your API key > ) as mpr:
    # do client operations here

Hi!I’m sorry I haven’t been able to see a reply after being busy.,I’ve already filled in the key in this part.。 After I followed your instructions, I filled in the new version of the key correctly in the API key code. However, it’s a shame that the results are still as I reported earlier.

We haven’t had reports of widespread outages, so it’s probably a local network issue. Can you try:

  • Using a VPN to get around internet service provider / governmental firewalls
  • Ensuring that any firewalls you use on your computer permit traffic to MP by accessing the API documentation or using the materials explorer app
  • Using a different network connection (e.g., ethernet, wifi at a cafe/work/school)?