OpenAI is not accessible with getaddrinfo
#3828
-
📦 EnvironmentDocker 📌 Versionv1.15.19 💻 Operating SystemUbuntu 🌐 BrowserFirefox 🐛 Bug DescriptionThe LobeChat is unable to access the OpenAI API, despite the server having successful access. This issue appears to be isolated to the LobeChat application, as other AI models (e.g., Claude, Perplexity) are functioning correctly. The server can successfully access the OpenAI API. The nextjs Docker container itself can access the OpenAI API. LobeChat frontend displays an error as shown. I am using a production docker-compose installation {
"error": {
"cause": {
"errno": -3008,
"code": "ENOTFOUND",
"syscall": "getaddrinfo",
"hostname": "api.openai.com"
}
},
"endpoint": "https://api.openai.com/v1",
"provider": "openai"
} I am able to access OpenAI from both VM and nextjs container: 📷 Recurrence Steps
🚦 Expected BehaviorLobeChat should be able to communicate with the OpenAI API successfully, as the server and Docker container can. 📝 Additional InformationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 20 comments 2 replies
-
Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. |
Beta Was this translation helpful? Give feedback.
-
Hey there, @unitythemaker! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this issue together! I found some similar issues that might be relevant to your problem:
Regarding your specific issue, the
By following these steps, you should be able to identify and resolve the DNS resolution issue affecting your LobeChat's connectivity to the OpenAI API. |
Beta Was this translation helpful? Give feedback.
-
I tried to manually add # Start a sh shell in container as root user
docker exec -u 0 -it lobe-database sh
# Open hosts file
vi /etc/hosts
# I added this line:
# 104.18.6.192 api.openai.com |
Beta Was this translation helpful? Give feedback.
-
@hezhijie0327 is this same as before? |
Beta Was this translation helpful? Give feedback.
-
I got the same error for |
Beta Was this translation helpful? Give feedback.
-
@unitythemaker have a try to mapping host's
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
More like related to this alpinelinux/docker-alpine#403 Could you run
if yes, run the following code in container, then restart the container.
|
Beta Was this translation helpful? Give feedback.
-
Unfortunately, container has a different one. Here you go:
|
Beta Was this translation helpful? Give feedback.
-
then could you run the code to overwrite |
Beta Was this translation helpful? Give feedback.
-
found in docker/for-linux#755 , caused by |
Beta Was this translation helpful? Give feedback.
-
I tried it, it couldn't reach database via
|
Beta Was this translation helpful? Give feedback.
-
nonono... I mean run this to replace, or using text-editor to modify
|
Beta Was this translation helpful? Give feedback.
-
Oh, okay. |
Beta Was this translation helpful? Give feedback.
-
Interesting... The thing I don't understand is how app can't reach but tools like nslookup, curl even nodejs in the container is able to reach. |
Beta Was this translation helpful? Give feedback.
-
I added this lines in docker-compose and now the solution is permanent! dns:
- 8.8.4.4
- 8.8.8.8 Btw, I checked /etc/resolv.conf after adding dns option and interestingly it's the same but see the comment (ExtServers):
|
Beta Was this translation helpful? Give feedback.
-
This issue is closed, If you have any questions, you can comment and reply. |
Beta Was this translation helpful? Give feedback.
-
create a file to save dns configuration like
|
Beta Was this translation helpful? Give feedback.
-
I am using Zeaber and dockerfile, but this problem also occurs |
Beta Was this translation helpful? Give feedback.
The --dns configuration will be overridden by the storage space mapping configuration file, so it is recommended that if you set the DNS configuration file on the storage space mapping host, you do not need to configure DNS in docker-compose anymore. And it is recommended to change the mapping method to read-only access like this:
To prevent the container service from modifying this configuration file on the host after startup.