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

Closed
opened 2026-02-15 16:27:22 -05:00 by yindo · 2 comments
Owner

Originally created by @RussellXY on GitHub (Jan 18, 2024).

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: 
Originally created by @RussellXY on GitHub (Jan 18, 2024). 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](https://github.com/jmorganca/ollama-python/assets/8545620/5ec8ad93-e1e4-45d8-8701-139dc8a2b903) ``` 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: ```
yindo closed this issue 2026-02-15 16:27:22 -05:00
Author
Owner

@mxyng commented on GitHub (Jan 18, 2024):

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(...)

@mxyng commented on GitHub (Jan 18, 2024): 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(...)`
Author
Owner

@RussellXY commented on GitHub (Jan 18, 2024):

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🙏

@RussellXY commented on GitHub (Jan 18, 2024): > 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🙏
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#3