title: FastAPI Service Results in 404 when service is started using uvicorn.run
body: <p>New to FastAPI and uvicorn, but I'm wondering why when I run my &quot;hello world&quot; service by starting it using uvicorn from the command line, it works fine, but when using the &quot;uvicorn.run&quot; method from inside my service, the service starts, but when I send a GET I always get a 404 with a response body of {&quot;detail&quot;: &quot;Not Found&quot;}?</p>
  <p>Here is my code:</p>
  <pre><code>import uvicorn
  from fastapi import FastAPI
  
  app = FastAPI()
  uvicorn.run(app, host=&quot;127.0.0.1&quot;, port=5049)
  
  
  @app.get(&quot;/&quot;)
  async def root():
      return {&quot;message&quot;: &quot;Hello World&quot;}
  </code></pre>
  <p>That always returns with a 404 as follows:</p>
  <pre><code># curl http://127.0.0.1:5049/
  {&quot;detail&quot;:&quot;Not Found&quot;}
  </code></pre>
  <p>The output from my service shows:</p>
  <pre><code>INFO:     Started server process [28612]
  INFO:     Waiting for application startup.
  INFO:     Application startup complete.
  INFO:     Uvicorn running on http://127.0.0.1:5049 (Press CTRL+C to quit)
  INFO:     127.0.0.1:55446 - &quot;GET / HTTP/1.1&quot; 404 Not Found
  </code></pre>
  <p>If I comment out the &quot;uvicorn.run&quot; line and then start the service from the command line with (running on Windows 10):</p>
  <pre><code>uvicorn.exe test:app --host=127.0.0.1 --port=5049
  </code></pre>
  <p>I get the correct response:</p>
  <pre><code># curl http://127.0.0.1:5049/
  {&quot;message&quot;:&quot;Hello World&quot;}
  </code></pre>