#πŸ”’ Need Help Exposing My Windows Flask Server via Serveo – Getting HTTP 502 Error

9 messages Β· Page 1 of 1 (latest)

sage drift
#

Hi all,

I'm trying to run a simple Flask server on my Windows machine and expose it to the public internet using Serveo. I'm on a restricted network (College Public WiFi), so I can't use traditional port forwarding.

I set up a basic Flask app (binding to 0.0.0.0 on port 5000). Local access on my Windows machine works perfectly. For example, accessing http://localhost:5000 returns my expected "Hello" message.
I then open a new terminal and run:
ssh -R 80:localhost:5000 serveo.net
This command returns a URL like:
https://randomnumbersandletters.serveo.net
My terminal even logs an incoming HTTP request from an external IP when trying to access it from my phone.

When I try to access the Serveo URL from my phone, I get an HTTP 502 error ("Bad Gateway"). The error seems to indicate that Serveo isn’t receiving a proper response from my Flask backend.

I've verified that the Flask server is running correctly by using curl http://localhost:5000 on my Windows machine. I've ensured my Flask app is bound to 0.0.0.0 so that it listens on all interfaces. I've confirmed that local access works fine. I've checked that the SSH tunnel is established and logging incoming requests.

What could be causing this HTTP 502 error when accessing via Serveo?

Thanks in advance for your help.

haughty fulcrumBOT
#

@sage drift

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sage drift
#

II made it work, I just typed ssh -R 80:127.0.0.1:8000 serveo.net instead and now everything runs correctly. If someone could explain why this works it would be amazing, I would like to learn

stuck lagoon
#

Don't you need to forward port 443 as well or does serveo handle https certs?

Can you connect to any service through serveo at all, e.g. nginx, or python -m http.server?

#

Never mind, you've got it working - well done!
I've heard of localhost causing a slight delay while that alias is resolved, e.g. to 127.0.0.1, but have no further clue. I'd love to know why too.

stuck lagoon
#

No problem. Please don't expose python -m http.server to the wild. I'd look into securing flask too (can it be run behind uvicorn), or running flask in a local docker container.

haughty fulcrumBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.