ollama / ollama-python

Ollama Python library
https://ollama.com
MIT License
2.75k stars 227 forks source link

Server error '502 Bad Gateway' for url 'http://127.0.0.1:11434/api/chat' #14

Closed RussellXY closed 5 months ago

RussellXY commented 5 months ago

I'm sure the ollama service is running with this command: ollama serve. but I still got this when run the sample code:

截屏2024-01-18 21 53 11

Exception has occurred: ResponseError
Server error '502 Bad Gateway' for url 'http://127.0.0.1:11434/api/chat'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502
httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://127.0.0.1:11434/api/chat'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502

During handling of the above exception, another exception occurred:

  File "/Users/xiongyu/Documents/python_project/youtube_translator/optimize.py", line 11, in <module>
    for part in ollama.chat('llama2:13b', messages=messages, stream=True):
ollama._types.ResponseError: 
mxyng commented 5 months ago

Where is your ollama service running? If it's not locally on port 11434, you'll need to change it by setting the OLLAMA_HOST environment variable or creating a custom client ollama.Client(base_url='...').chat(...)

RussellXY commented 5 months ago

Where is your ollama service running? If it's not locally on port 11434, you'll need to change it by setting the OLLAMA_HOST environment variable or creating a custom client ollama.Client(base_url='...').chat(...)

I'm sorry, it's my fault. I'm using a VPN for all network requests on my computer, that's the reason for the 502 bad gateway thank you for your reply🙏