I’m experiencing persistent DNS resolution errors when trying to access https://api-inference.huggingface.co from within my Space.
My space is running on Nvidia 1xL4 hardware and I am receiving this error no matter which text-generation model I use: requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘api-inference.huggingface.co’, port=443): Max retries exceeded with url: … (Caused by NameResolutionError: Failed to resolve ‘api-inference.huggingface.co’ ([Errno -2] Name or service not known))
I’ve verified that:
requests.get("https://www.google.com") works from the same Space
The domain resolves externally (confirmed via nslookup and curl on my local machine)
Changing hardware tiers does not resolve the issue
It appears to be a DNS or routing misconfiguration inside the Space environment. Is there anyway I can fix this or try to resolve this? If there is anymore information I can provide please let me know.
I get the same error when running a new version of a python shiny chatbot in my huggingface space but the same code can access the Mistral model on huggingface when it is running locally. The hf configuration worked previously but when I uploaded a new version today I get the “Failed to resolve ‘api-inference.huggingface.co’” Putting a check in the dockerfile shows it can ping and access the url but no joy when trying to run the code
I seem to be getting the same issue. I am only using the Basic Free hardware, but any model I run on the space gives that same exact error. Is this a problem on my end? Or is this happening to everyone?
what’s wrong with those hf models?? i have a review today and i am unable to get the results by using those base models how can i explain this to them right now
I tried sending multiple requests to several text-generation models but I am still getting the error “requests.exceptions.ConnectionError: (MaxRetryError('HTTPSConnectionPool(host='api-inference.huggingface.co', port=443): Max retries exceeded with url: … (Caused by NameResolutionError(”<urllib3.connection.HTTPSConnection object at …>: Failed to resolve 'api-inference.huggingface.co' ([Errno -2] Name or service not known)“))'), ‘(Request ID: …)’)” Is there any new information on how to resolve this or if a fix is coming soon? Thank you!
The user is experiencing persistent DNS resolution errors when trying to access the Hugging Face API from within their Space. The error message indicates a failure to resolve the domain ‘api-inference.huggingface.co’.
To troubleshoot this issue, here are some steps you can take:
Verify DNS Resolution: You’ve already confirmed that the domain resolves externally using nslookup and curl on your local machine. This suggests that the issue is specific to the Space environment.
Check Network Configuration: Ensure that the Space’s network configuration allows for DNS resolution. You can try using a different DNS resolver or checking the Space’s network settings.
Test with Different Models: You’ve already tried different text-generation models, which rules out model-specific issues.
Hardware Tier: Changing hardware tiers didn’t resolve the issue, so it’s unlikely related to the Nvidia 1xL4 hardware.
External Connectivity: You’ve verified that requests to other domains (e.g., https://www.google.com) work from the same Space, indicating that external connectivity is not the problem.
Given these steps, the issue seems to be related to DNS resolution within the Space environment. You may want to reach out to the Hugging Face support team for further assistance, as they can investigate the issue specific to their platform.
Additional information you can provide to the support team includes:
The exact error message and stack trace
The Space’s configuration and network settings
Any recent changes made to the Space or its environment
By providing this information, you can help the support team better understand the issue and provide a more effective solution.
The image shows a Python error message, specifically a ConnectionError caused by a NameResolutionError. This error occurs when the program is unable to resolve the hostname of the API endpoint it is trying to connect to.
To fix this issue, you can try the following accommodations:
Check your internet connection: Ensure that your internet connection is stable and working properly.
Verify the API endpoint URL: Double-check that the API endpoint URL is correct and properly formatted.
Check for DNS resolution issues: Try using a different DNS resolver or check if there are any DNS resolution issues in your network.
Increase the timeout: You can try increasing the timeout value for the API request to see if it resolves the issue.
Retry the request: You can implement a retry mechanism to retry the request after a certain amount of time.
Here is an example of how you can implement a retry mechanism using the tenacity library:
import tenacity
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, min=4, max=10))
def make_api_request():
# Your API request code here
pass
This will retry the API request up to 3 times with an exponential backoff if it fails due to a ConnectionError.
It seems the problem still exists. I see the same error message in my app’s log:
requests.exceptions.ConnectionError: (MaxRetryError('HTTPSConnectionPool(host=\'api-inference.huggingface.co\', port=443): Max retries exceeded with url: /models/HuggingFaceH4/zephyr-7b-beta/v1/chat/completions (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f6830d437c0>: Failed to resolve \'api-inference.huggingface.co\' ([Errno -2] Name or service not known)"))'), '(Request ID: f95be599-06ed-42f0-8ad1-3aaea69c2001)')
In an SSH session to my HF Space application, I also see DNS resolution issues:
user@r-datenoio-dateno-chatbot-vhhwdmgc-9fea7-ax3og:~/app$ curl api-inference.huggingface.co
curl: (6) Could not resolve host: api-inference.huggingface.co
user@r-datenoio-dateno-chatbot-vhhwdmgc-9fea7-ax3og:~/app$ cat /etc/resolv.conf
search ec2.internal
nameserver 10.108.0.2
options timeout:2 attempts:5
Among the issues that arose after the hardware replacement, the remaining issues that need to be addressed by Hugging Face are…
SentenceTransformers endpoint issue seems to be being worked on by tomarrsen, so that should be fixed soon.
HF may have forgotten to announce that PyTorch 2.0.0 no longer works with Zero GPU (due to A100 being replaced with H200). Even major companies like Tencent haven’t noticed…
There is a possibility that the Pro token application for Gradio API calls (fixed in 5.12.0) may have broken again during the replacement. It seems that Pro is not recognized even in version 5.29.0.