title: How do I request my fast API from Python?
body: <p>I am running my fastapi via Docker, here is the main.py</p>
  <pre><code>import sys
  from fastapi import FastAPI
  from src.redactor import DSARRedaction
  
  app = FastAPI()
  
  @app.get(&quot;/&quot;)
  async def run_redaction():
      DSARRedaction(&quot;kulveer&quot;).run_redaction()
      return {&quot;message&quot;: &quot;Redaction Completed&quot;}
  </code></pre>
  <p>and here is the Dockerfile</p>
  <pre><code>FROM python:3.8-slim-buster
  
  WORKDIR /app
  
  COPY requirements.txt .
  
  RUN apt-get update 
  RUN apt-get install -y python3-opencv
  # Install dependencies for textract
  RUN apt-get install -y ghostscript python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig \
  libpulse-dev zlib1g-dev qpdf
  RUN apt -y install tesseract-ocr
  RUN apt -y install libtesseract-dev
  RUN pip install --upgrade pip &amp;&amp; pip install -r requirements.txt
  
  COPY . .
  
  RUN python3 -m spacy download en_core_web_lg
  
  EXPOSE 50
  
  CMD [&quot;uvicorn&quot;, &quot;main:app&quot;, &quot;--host&quot;, &quot;0.0.0.0&quot;, &quot;--port&quot;, &quot;50&quot;]
  </code></pre>
  <p>I am trying to run the following python script as I just want to be able to get the URL via python without having to click on it.</p>
  <pre><code>import requests
  
  requests.get('http://0.0.0.0:50/')
  </code></pre>
  <p>But every time I try to run that code to request the API, I get the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/connection.py&quot;, line 174, in _new_conn
      conn = connection.create_connection(
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py&quot;, line 96, in create_connection
      raise err
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py&quot;, line 86, in create_connection
      sock.connect(sa)
  ConnectionRefusedError: [Errno 111] Connection refused
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py&quot;, line 699, in urlopen
      httplib_response = self._make_request(
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py&quot;, line 394, in _make_request
      conn.request(method, url, **httplib_request_kw)
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/connection.py&quot;, line 239, in request
      super(HTTPConnection, self).request(method, url, body=body, headers=headers)
    File &quot;/usr/local/lib/python3.8/http/client.py&quot;, line 1256, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File &quot;/usr/local/lib/python3.8/http/client.py&quot;, line 1302, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File &quot;/usr/local/lib/python3.8/http/client.py&quot;, line 1251, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File &quot;/usr/local/lib/python3.8/http/client.py&quot;, line 1011, in _send_output
      self.send(msg)
    File &quot;/usr/local/lib/python3.8/http/client.py&quot;, line 951, in send
      self.connect()
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/connection.py&quot;, line 205, in connect
      conn = self._new_conn()
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/connection.py&quot;, line 186, in _new_conn
      raise NewConnectionError(
  urllib3.exceptions.NewConnectionError: &lt;urllib3.connection.HTTPConnection object at 0x7f34d008fca0&gt;: Failed to establish a new connection: [Errno 111] Connection refused
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.8/site-packages/requests/adapters.py&quot;, line 439, in send
      resp = conn.urlopen(
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py&quot;, line 755, in urlopen
      retries = retries.increment(
    File &quot;/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py&quot;, line 574, in increment
      raise MaxRetryError(_pool, url, error or ResponseError(cause))
  urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=50): Max retries exceeded with url: / (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x7f34d008fca0&gt;: Failed to establish a new connection: [Errno 111] Connection refused'))
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;x.py&quot;, line 3, in &lt;module&gt;
      requests.Session().get('http://0.0.0.0:50')
    File &quot;/usr/local/lib/python3.8/site-packages/requests/sessions.py&quot;, line 555, in get
      return self.request('GET', url, **kwargs)
    File &quot;/usr/local/lib/python3.8/site-packages/requests/sessions.py&quot;, line 542, in request
      resp = self.send(prep, **send_kwargs)
    File &quot;/usr/local/lib/python3.8/site-packages/requests/sessions.py&quot;, line 655, in send
      r = adapter.send(request, **kwargs)
    File &quot;/usr/local/lib/python3.8/site-packages/requests/adapters.py&quot;, line 516, in send
      raise ConnectionError(e, request=request)
  requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=50): Max retries exceeded with url: / (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x7f34d008fca0&gt;: Failed to establish a new connection: [Errno 111] Connection refused'))
  </code></pre>
  <p>Any ideas on why this is happening?</p>