Issue with multiple users accessing my Flet Web App
amgartendev
TRIALOP

a year ago

I'm developing a web application using Flet and Python, and I'm hosting it on Railway. My goal is to have a single instance of my app running, allowing multiple users to connect without issues, just like a normal web app.

However, I'm encountering a problem:
- When I run my app locally using (basically running the app and binding the port 8000):
flet run .\main.py -w -p 8000
It works fine

- But if I try to start another instance on the same port, I get this error:
ERROR: [Errno 10048] error while attempting to bind on address ('::', 8000, 0, 0): [WinError 10048] only one usage of each socket address (protocol/network address/port) is normally permitted

- Also, when deployed on Railway, it seems like every new user request tries to bind the port again, which shouldn't happen.

What I'm trying to achieve:
- I want my app ro run as a single instance where multiple users can cnnect, just like any website
- Each user should have their own session without interfering with others

My current code (simplified)
```import flet as ft
import os

def main(page: ft.Page):
page.title = "My Flet App"
page.add(ft.Text("Hello, world!"))

PORT = int(os.environ.get("PORT", 8000)) # Use Railway's assigned port

ft.app(target=main, port=PORT, view=ft.WEB_BROWSER) # Start server```

Useful Link
I've been searching for a while and found this in Railway's documentation:
"Note: If your application needs to be accessible over both public and private networks, your application server must support dual stack binding. Most servers handle this automatically when listening on ::, but some, like Uvicorn, do not."

link to this doc: https://docs.railway.com/guides/public-networking

Can someone help me?

15 Replies

amgartendev
TRIALOP

a year ago

826548a8-d043-48d4-9bf2-b274d50f9a26


a year ago

how are you running the flet app while on Railway


amgartendev
TRIALOP

a year ago

cd client && python main.py


amgartendev
TRIALOP

a year ago

but i've already tried cd client && flet run main.py -w


a year ago

please provide errors


amgartendev
TRIALOP

a year ago

ERROR: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 48901): [winerror 10048] only one usage of each socket address (protocol/network address/port) is normally permitted


amgartendev
TRIALOP

a year ago

I think the problem is how I'm rendering the components of my app, but i works fine locally


amgartendev
TRIALOP

a year ago

idk


a year ago

is this an isolated or shared monorepo?


amgartendev
TRIALOP

a year ago

it is a shared monorepo


a year ago

what is your current start command


amgartendev
TRIALOP

a year ago

For the Server it is cd server && python main.py
For the Client it is cd client && python main.py

1344404130705309700


a year ago

neither have deploys?


amgartendev
TRIALOP

a year ago

I just shutted it down so I don't waste my $5 free trial… Times are tough man 😅 Just kidding, it was deployed so I could test the platform and pay for a plan


amgartendev
TRIALOP

a year ago

But it returned the error above


Loading...