I'm running two Flask apps on two separate Docker containers together on localhost, with port mapping 3000:3000 and 5000:5000. Each of them has a route that accepts a POST request and do some functions. Here's the code for app 1:
@app.route('/preprocess', methods=['POST'])
def app_preprocess():
    req_data = request.get_json()
    bucket = req_data['bucket']
    input_file = req_data['input']
    upload_file = input_file + "_1"
    # do some functions
    to_send = {"bucket": bucket, "input": upload_file}
    to_send_string = json.dumps(to_send)
    requests.post("http://127.0.0.1:3000/postprocess", json=to_send_string)
    return "Sent request to 2"
if __name__ == "__main__":
    app.run(debug=True, host='0.0.0.0', port=5000)
And app 2:
@app.route('/postprocess', methods=['POST'])
def app_postprocess():
    req_data = request.get_json()
    bucket = req_data['bucket']
    input_file = req_data['input']
    upload_file = input_file + "_2"
    # do some functions
    return "Uploaded 2"
if __name__ == "__main__":
    app.run(debug=True, host='0.0.0.0', port=3000)
I used Postman to send the POST request to each app separately. Both app 1 and 2 does its job (the "do some functions" bit). App 2 would return "Uploaded 2" nicely.
App 1 stopped at the requests.post part, and returning an error:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=3000): Max retries exceeded
        with url: /postprocess (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at
        0x7f74d3fc6b10>: Failed to establish a new connection: [Errno 111] Connection refused')) // Werkzeug Debugger
Please help with fixing this, thank you. Also I'm a novice at Flask and HTTP routing so I might missed something.
EDIT: here's the docker-compose.yaml
version: '3'
services:
  uploader-1:
    build: ./uploader-1
    image: uploader-1
    container_name: uploader-1
    ports:
        - 5000:5000
  uploader-2:
    build: ./uploader-2
    image: uploader-2
    container_name: uploader-2
    ports:
        - 3000:3000
 
     
     
    