Matteo Siotto
Matteo Siotto

Reputation: 11

Problem deploying python Fastapi on replit with sentence_transformers

I am having a problem deploying my Fastapi app on replit. In a month all works fine but since 24-01-25 if I run the application in local env it works fine, but when I redeploy it in production I have this error:

2025-01-27T15:54:11Z error: The application must serve traffic on either port 80 (if configured) or the first port in the port configuration. This port was never opened. Check the logs for more information.

main.py:

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=80)

Here is my .replit file:

run = ["uvicorn", "main:app", "--host", "0.0.0.0", "--reload"]
modules = ["python-3.10:v18-20230807-322e88b"]

hidden = [".pythonlibs"]

[nix]
channel = "stable-23_05"

[deployment]
run = ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 80"]
deploymentTarget = "cloudrun"

[[ports]]
localPort = 8000
externalPort = 80

I forced ports in run command and in the main as the AI assistant suggested: run command: uvicorn main:app --host 0.0.0.0 --port 80

In my service I import sentence_transformers and possibly it was a problem with the library update released on 23-01-25 so I rollback it to the previous working version (3.3.1). If I comment the import and the usage (like the following snippet) the deploy works fine.

from sentence_transformers import SentenceTransformer

model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')

Anyone is having this problem and can help me?

Thanks a lot!

Upvotes: 1

Views: 92

Answers (0)

Related Questions