2 months 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?
0 Replies
2 months ago
how are you running the flet app while on Railway
cd client && python main.py
2 months ago
please provide errors
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
I think the problem is how I'm rendering the components of my app, but i works fine locally
2 months ago
is this an isolated or shared monorepo?
2 months ago
what is your current start command
For the Server it is cd server && python [main.py](main.py)
For the Client it is cd client && python [main.py](main.py)
2 months ago
neither have deploys?
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