reflex: Connection Error Displayed Upon Server Restart

Describe the bug Upon file modification and server restart, this message keep getting displayed and slows down dev process. how can this be stopped ?

Connection Error Cannot connect to server: timeout. Check if server is reachable at http://localhost:8000

To Reproduce Steps to reproduce the behavior:

reflex run

Expected behavior Page reload should not display this message. Screenshots If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version: 3.10.4
  • Reflex Version: 0.2.7
  • OS: Win11
  • Browser (Optional):

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Reactions: 2
  • Comments: 17

Most upvoted comments

Just chiming in to say that I also have this problem.

I just tried Reflex for the very first time, and installed it in a fresh Python (3.11) environment. Reflex 0.2.7.

All I get is this:

Connection Error
Cannot connect to server: websocket error. Check if server is reachable at http://localhost:8000

image

And that’s on a brand new project with zero customization. Hiding the modal seems like a bad solution, tucking the problem away…

yes, i see that it fails:

Console tab:

image

Network tab:

image

I also got those wired timeout and websocket errors, but only on the remote VM where I’m hosting the app. If I run the app locally, there are no problems.

In my case, it turned out that I was developing on reflex 0.3.1, but it was 0.2.9 (or something like this) on the VM.

I’ve updated the lib to 0.3.2 on the VM, manually deleted the .web dir, reinitialized the app, and now it works.

I too faced this issue on a brand new install, and resolved it by forwarding the default 8000 port in VSCode:

CleanShot 2023-09-27 at 12 30 59@2x

@99hats if you change the backend_port, then you must also change the api_url to point to that port.

The api_url should be a publicly accessible URL where the backend is running that the frontend will connect to.

If you’re hosting the backend on example.com:3040, then set api_url="http://example.com:3040"

if you don’t want the overlay when the websocket is down, you can pass

app = rx.App(overlay_component=None)

I’m curious about this part though

this message keep getting displayed and slows down dev process

The message should only be displayed when the backend is disconnected, which means that the app would be non-interactive for the same amount of time. Are you finding that the app takes longer to restart with the modal pop up?