Skip to main content

Command Palette

Search for a command to run...

Gitpod+Flask: Port Not Found Error in Preview Browser

Published
1 min read

After spending hours trying to figure out why gitpod shows the "Port not found" error page instead of our flask-based application's index page, the diagnosis is:

  1. The root cause of the problem is still unknown.
  2. Most likely this is caused by unexpected behavior of flask as on startup it briefly opens and closes the port and just moments later reopens it again.
  3. I think that the first time flask opens the port, gitpod detects that and opens the preview browser which, unfortunately, sends its request to the port just after flask closed it, which causes the browser to show the error page.
  4. It is possible to use socat (or a similar tool) to fix the issue.
  5. To do so, instruct gitpod to ignore flask's port and open preview on some other port, i.g. 8080.
  6. Start your flask app and then run socat like this: socat TCP-LISTEN:8080,fork TCP4:localhost:5000

socat (SOcket CAT) is a great tool!

More from this blog

Решил написать книгу

И даже название уже есть: "Resurrecting God". Ага, будет на английском. Перевод на русский запрещу, только на украинский. О чем она будет? Знающие, наверное, уже догадались — о философии и о возвращении нашей жизни уничтоженного эпохой просвещения см...

Mar 7, 20231 min read

Down from the metal, up through the cloud and back to the UX

16 posts