Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.3K
Views
Running fastapi app using uvicorn on ubuntu server

I am dealing with the project deposition made on FastAPI to a remote ubuntu server. I'll try to run the project from terminal (using SSH connection) by the command

gunicorn -k uvicorn.workers.UvicornWorker main:app

The output is

gunicorn -k uvicorn.workers.UvicornWorker main:app
[2020-07-14 15:24:28 +0000] [23102] [INFO] Starting gunicorn 20.0.4
[2020-07-14 15:24:28 +0000] [23102] [INFO] Listening at: http://127.0.0.1:8000 (23102)
[2020-07-14 15:24:28 +0000] [23102] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2020-07-14 15:24:28 +0000] [23104] [INFO] Booting worker with pid: 23104
[2020-07-14 15:24:28 +0000] [23104] [INFO] Started server process [23104]
[2020-07-14 15:24:28 +0000] [23104] [INFO] Waiting for application startup.
[2020-07-14 15:24:28 +0000] [23104] [INFO] Application startup complete.

But I need the project to be available at the IP address of the server. If I try smth like

uvicorn main:app --host 66.226.247.55 --port 8000 

I get

INFO:     Started server process [23308]
INFO:     Waiting for application startup.
INFO:     Connected to database postgresql://recognition:********@localhost:5432/reco
INFO:     Application startup complete.
ERROR:    [Errno 99] error while attempting to bind on address ('66.226.247.55', 8000): cannot assign requested address
INFO:     Waiting for application shutdown.
INFO:     Disconnected from database postgresql://recognition:********@localhost:5432/reco
INFO:     Application shutdown complete.

Where 66.226.247.55 - external IP adress from google cloud platform instances How do I start a project so that it can be accessed via IP?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

The --host should be the local address of your GCP server.

uvicorn main:app --host 0.0.0.0 --port 8000

and now access the application by http://66.226.247.55:8000

Note: You should open your 8000 port of GCP server.

over 4 years ago · Santiago Trujillo Report

0

If you're using nginx server

create a file in /etc/nginx/sites-enabled/ create file touch fastapi_nginx copy code into file and adjust accordingly

server{
    listen 80;
    server_name "your public ip";
    location / {
        proxy_pass http://127.0.0.1:8000; #localhost
    }

}

This should reroute to your public ip

over 4 years ago · Santiago Trujillo Report

0

You cannot launch your fast api app on your local to your remote server in GCP.

You must deploy your app to GCP. In other words you need to run that command on a remote server not your localhost.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!