3

I have an Raspbery pie installed with ubuntu server, running Prefect. When I use my personal pc, I can get Prefect to run and start up an UI server:

>>> prefect server start Check out the dashboard at http://127.0.0.1:4200 

with my personal pc running this code, I can access this UI website.

I've sent this working code to my Raspberry Pie, which I can access with via SSH (SSH [email protected]) to and start the code. When I run the code from via SSH, I get:

>>> prefect server start Check out the dashboard at http://127.0.0.1:4200 

But now I am not sure how to access this UI website from my personal pc. Any ideas? I searched for help but so far I didn't have any lucks with the tips I read.

5
  • This one is tricky for new SSH users, but assuming that your Pii and your desktop are coexisting in the same LAN: 127.0.0.1 shares the same IP address as the Pi. Try http://<LAN IP Address of Pi>:4200
    – eyoung100
    CommentedMay 28, 2024 at 16:15
  • Thanks for the help, but it didn't work for me sadly. I double checked my server was runningCommentedMay 29, 2024 at 17:50
  • should I open up the router ip somehow @eyoung100 ?CommentedMay 29, 2024 at 17:50
  • What is the IP of the Pi?. I'm guessing something like 192.168.1.X, so in your PC's web browser, when you type http://192.168.1.X:4200 what happens? I need more than Didn't Work.
    – eyoung100
    CommentedMay 29, 2024 at 19:13
  • Thanks for helping me @eyoung100. Typing http://192.168.1.X:4200 in my pc site is not found. When I login via ssh locally, I use the ip 192.168.0.212 to access my Pi. I guess that must the the lan Ip adress of Pi you defined for me. http://192.168.0.212:4200/does nothing on my pc.CommentedMay 30, 2024 at 11:05

5 Answers 5

3
(prefect) $ prefect server start --help Usage: prefect server start [OPTIONS] Start a Prefect server instance ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ --host TEXT [default: (from PREFECT_SERVER_API_HOST)] │ │ --port INTEGER [default: (from PREFECT_SERVER_API_PORT)] │ │ --keep-alive-timeout INTEGER [default: (from PREFECT_SERVER_API_KEEPALIVE_TIMEOUT)] │ │ --log-level TEXT [default: (from PREFECT_LOGGING_SERVER_LEVEL)] │ │ --scheduler --no-scheduler [default: (from PREFECT_API_SERVICES_SCHEDULER_ENABLED)] │ │ --analytics-on --analytics-off [default: (from PREFECT_SERVER_ANALYTICS_ENABLED)] │ │ --late-runs --no-late-runs [default: (from PREFECT_API_SERVICES_LATE_RUNS_ENABLED)] │ │ --ui --no-ui [default: (from PREFECT_UI_ENABLED)] │ │ --help Show this message and exit. │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ 

You can use --host to change the IP that the server instance binds to. If you want it to be accessible via any IP address assigned on the Pi, you can use 0.0.0.0. If you only want it to respond to the access via e.g. the LAN IP of the Pi, you can use the specific address instead, namely 192.168.0.212 in your case.

Note that using a specific IP means that you won't be able to access it via 127.0.0.1. Also, binding to a specific IP does NOT mean that access via interfaces that is not assigned with the IP would be ignored. If you want to make sure it is exposed to only a specific network interface, you'll need configure corresponding firewall rules.

    2
    +50

    To access the UI server running on your Raspberry Pi from your personal PC, follow these steps:

    Step-by-Step Solution

    1. Confirm Server Running on Raspberry Pi:

      • Ensure that the prefect server is running on the Raspberry Pi and listening on the correct port (4200).
      prefect server start 
      • Verify the server is running by checking the output. It should indicate it's accessible at http://127.0.0.1:4200.
    2. Identify Raspberry Pi's IP Address:

      • Verify the IP address of your Raspberry Pi on your local network. If you can SSH into it using 192.168.0.212, then this is its LAN IP.
    3. Check Firewall/Port Forwarding:

      • Ensure there are no firewall rules blocking port 4200. You can temporarily disable the firewall to check if this is causing the issue.
      sudo ufw status sudo ufw allow 4200 
    4. Access via LAN IP:

      • On your personal PC, open a web browser and navigate to http://192.168.0.212:4200.
    5. SSH Port Forwarding (Alternative Method):

      • If the above method does not work, use SSH port forwarding to forward the port from your Raspberry Pi to your personal PC.
      ssh -L 4200:localhost:4200 [email protected]
      • After establishing the SSH connection with port forwarding, open a web browser on your personal PC and navigate to http://localhost:4200. This forwards the traffic from your PC's port 4200 to the Raspberry Pi's port 4200.

    Additional Troubleshooting

    1. Check if the Service is Running Correctly:

      • Ensure the prefect server is not facing any errors while starting. Check the logs for any issues.
    2. Verify Network Connectivity:

      • Ensure that your personal PC and Raspberry Pi are on the same network and can ping each other.
      ping 192.168.0.212 
    3. Check Listening Ports:

      • Verify that the Raspberry Pi is listening on port 4200.
      sudo netstat -tuln | grep 4200 
      • This command should show an entry indicating that the Pi is listening on port 4200.

    Example Scenario

    1. Run Prefect Server on Raspberry Pi:

      prefect server start 

      Output:

      Check out the dashboard at http://127.0.0.1:4200 
    2. Access from Personal PC:

      • Open a web browser and go to:
      http://192.168.0.212:4200 
    3. Using SSH Port Forwarding:

      • Open a terminal on your personal PC and run:
      ssh -L 4200:localhost:4200 [email protected]
      • Then open a web browser and navigate to:
      http://localhost:4200 

    Following these steps should allow you to access the Prefect UI server running on your Raspberry Pi from your personal PC. If you encounter any specific error messages or issues, please provide those details for further assistance.

    1
    • thanks for writing this idiot-proof guide. Just something an idiot like me needed. And thanks for Simson, ctx, Tom Yan and sam for writing as well. This was simply the first thing I tried and worked right away.CommentedJun 3, 2024 at 7:13
    2

    Use ss -tlpn to check on which IP your service listens.

    If you cannot make perfect server to listen to 192.168.0.212 or 0.0.0.0 and you don't want to use an ssh tunnel which Simson described, you could install nginx and configure a reverse proxy, e.g:

    server { listen 192.168.0.212:80; location / { proxy_pass http://127.0.0.1:4200; proxy_http_version 1.1; } } 
      2

      It seems that you have missed a step in installation after installing perfect To fix the problem your having check your pi's ip then

      prefect config set PREFECT_API_URL=http://REPLACE-THIS:4200 

      replace REPLACE-THIS with its ip

      1
      • 1
        AFACIT PREFECT_API_URL is a variable used by the client part, that is, if the OP wants to used the CLI on his PC to connect to the server after fixing the server part on the Pi, he may need to set/change this variable on the PC. (Also, I think it should end with /api.)
        – Tom Yan
        CommentedJun 2, 2024 at 10:23
      1

      When you log in with ssh on your PI system, give a port forwarding argument on the command line

      ssh [email protected] -L 8888:localhost:4200 

      Then you will be able to connect from PC to http://localhost:8888/ and it will be routed to the raspberrypi. This connection will be present until you close down the ssh connection and log out.

      Make sure AllowTcpForwarding is set to yes in /etc/ssh/sshd_config on remote system

      AllowTcpForwarding yes 

      The other way would be to make sure your service is listing to all interfaces and not only to localhost on the pi.

      2
      • Thanks for the help @Simson, I didn't make it clear from my post, but it's a PI running ubuntu server. I guess the remotepi is something that comes default with some pi os? Anyways I get an expected error running this code: ssh: Could not resolve hostname remotepi: Temporary failure in name resolutionCommentedMay 31, 2024 at 11:55
      • 1
        No, remotepi is your server
        – ctx
        CommentedMay 31, 2024 at 13:09

      You must log in to answer this question.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.