<@ULVA73B9P> I have this docker-compose file to se...
# ask-marvin
s
@Marvin I have this docker-compose file to set up a server:
Copy code
version: "3.9"
services:
  prefect:
    image: prefecthq/prefect:2.10.21-python3.11
    container_name: prefect-server
    restart: unless-stopped
    volumes:
      - prefect:/root/.prefect
    entrypoint:
      [
        "/opt/prefect/entrypoint.sh",
        "prefect",
        "server",
        "start"
      ]
    environment:
      - PREFECT_API_URL=<http://my-ip:4300/api>
      - PREFECT_UI_URL=<http://my-ip:4300/api>
      - PREFECT_SERVER_API_HOST=0.0.0.0
      - PREFECT_SERVER_API_PORT=4300
      - PYTHONIOENCODING=utf-8
    ports:
      - 4300:4300

volumes:
  prefect:


networks:
  default:
    name: prefect-network
Then, in another machine, I set PREFECT_API_URL="http://my-ip:4300/api" and try the following deployment:
Copy code
from prefect import flow
from pleg_flows.tasks.reunioes import atualiza_reunioes_pleg
from prefect.deployments import Deployment
from datetime import date, timedelta

hoje = date.today()
data_ref = hoje - timedelta(days=5)
last_month = (hoje - timedelta(days=30)).strftime("%Y%m%d")


@flow(name="MongoDB PLEG", log_prints=True)
def fluxo_pleg():
    atualiza_reunioes_pleg(params={"ini": last_month}, last_update=data_ref)


if __name__ == "__main__":
    fluxo_pleg.serve(name="Atualiza Reunioes PLEG", cron="0 6 * * 1,2,3,4,5")
When I execute the script, I get error 502 (bad gateway). But I can go to http://my-ip:4300/dashboard and it works fine. What am I missing?
m
It seems like you're trying to connect to your Prefect server from another machine and you're encountering a 502 Bad Gateway error. This error typically means that one server received an invalid response from another server that it was accessing while attempting to load the web page or fill another request by the browser. Here are a few things you could check: 1. Network Accessibility: Ensure that the machine where you're running your script can access the Prefect server. You can test this by trying to ping the server's IP address from the machine where you're running your script. 2. Correct API URL: Make sure that the
PREFECT_API_URL
environment variable is set correctly in your script. It should match the
PREFECT_API_URL
in your docker-compose file. 3. Server Health: Check the health of your Prefect server. You can do this by checking the logs of your Prefect server. If there's an issue with the server, it should show up in the logs. 4. Firewall or Security Group Settings: Sometimes, firewall or security group settings can prevent one machine from accessing another. Check to see if there's a rule that might be blocking the connection. 5. Prefect Version Compatibility: Ensure that the Prefect version you're using in your script is compatible with the Prefect server version. You're using Prefect version 2.10.21 in your docker-compose file. Make sure you're using a compatible version in your script. If none of these suggestions work, you might want to consider reaching out to the Prefect community or support for more specific help.
n
Hi @Samuel Barbosa, Did you find a solution? I am also need to run a docker-compose of Prefect 2