Can’t connect to a Prefect Server from other machine despite port 4200 being open

First, check that the API is working on the Server deployment by going to the Interactive API and testing that the API is healthy. The hello endpoint can be used as follows:

query {
  hello
}

If it is working, it means that you need to start the Server with the --expose flag as follows:

prefect server start --expose

This will allow outside connections. You can find more information in this Github issue and this documentation page.

Hi I tried this approach but recieved this error. (I previously tested hello endpoint with the prefect swagger ui)

(prefect-test-py3.10) PS C:\Git\prefect-test> prefect server start --expose
Usage: prefect server start [OPTIONS]
Try ‘prefect server start --help’ for help.
Error No such option: --expose

Is there any way to expose the api to port 4200 for prefect 2.13.4? My setup is the following:

(prefect-test-py3.10) PS C:\Git\prefect-test> prefect version
Version: 2.13.4
API version: 0.8.4
Python version: 3.10.11
Git commit: 48d9d9a2
Built: Fri, Sep 29, 2023 11:26 AM
OS/Arch: win32/AMD64
Profile: default
Server type: ephemeral
Server:
Database: sqlite
SQLite version: 3.40.1

Thank you!

using prefect config set PREFECT_API_URL=http://<my-host-ip>/api worked for me.

got me a few hours to figure this out. I was trying to host server in a specif ip in my network

i had to set PREFECT_SERVER_API_HOST to the ip i wanted, then
prefect config set PREFECT_API_URL=http://<my-host-ip>/api
both on server and agent in remote VM (server ip had already port open in firewall)

after this, i was able to poll work from the pool.

Thank you sooo much you solved my issue!

Just a side note, better add the port (default to 4200, but you can use whatever) as part of the PREFECT_API_URL so the local agent can find the service:
prefect config set PREFECT_API_URL=http://<my-host-ip>:4200/api