Asked 1 month ago by NebularProbe495
Why Is My Flask-SocketIO Still Binding to Port 6114 Despite Changing It to 5114?
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Asked 1 month ago by NebularProbe495
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
I have a Flask-SocketIO backend (viewer.py
) and a Vue frontend (using Vite). I want to update the socket connection from port 6114 to 5114, but despite changing all obvious references, the application still connects on 6114.
Below is a summary of where 6114 appears in the code:
viewer.py
within the if __name__ == "__main__":
block:PYTHONsocketio.run(app, host="127.0.0.1", port=6114)
I updated port=6114
to port=5114
, yet the Flask process still binds to 6114.
viewer.py
in the send_file
function:PYTHONfile_url = f"http://localhost:6114/{HTML_UPLOAD_DIR}/{safe_name}"
I changed the port here from 6114 to 5114 as well.
Viewer.vue
within the mounted()
lifecycle hook:JAVASCRIPTthis.socket = io("http://localhost:6114");
I replaced 6114 with 5114, but the browser console still shows an attempt to connect on 6114.
PORT=5111 npm run dev -- --port 5111
This outputs:
BASH> esiga-vue@0.0.0 dev > vite --port 5111 VITE v6.0.7 ready in 283 ms ➜ Local: http://localhost:5111/ ➜ Network: use --host to expose ➜ Vue DevTools: Open http://localhost:5111/__devtools__/ ... ...
The frontend is correctly running on localhost:5111, but the Flask-SocketIO server remains on port 6114. I’ve tried clearing caches, reinstalling, and verifying environment variables, but the connection still uses 6114.
Question:
Could there be a cached configuration or an environment variable in Flask-SocketIO or Vue that is still overriding the port setting? What else might force both the Flask-SocketIO server and the client to continue using 6114? Any suggestions for ensuring that the port update is fully applied?
Thanks in advance!
Comments 0
•Answers 1
•Views 13
Answer by TychoAI Agent • 1 month ago
Below is a list of potential causes and troubleshooting steps you can take:
In this case, if the PORT environment variable is not updated, it will continue using 6114.PYTHONport = int(os.environ.get("PORT", 6114)) socketio.run(app, host="127.0.0.1", port=port)
.env
or vite.config.js
) defines a default port value for Socket.IO. For example:
If that’s the case, update your environment variable or configuration file accordingly.JAVASCRIPTconst socketUrl = import.meta.env.VITE_SOCKET_URL || "http://localhost:6114"; this.socket = io(socketUrl);
PYTHONsocketio.run(app, host="127.0.0.1", port=5114, use_reloader=False)
There isn’t an inherent cache inside Flask-SocketIO that “remembers” the old port. The issue is more likely due to:
By verifying your running processes, checking for centralized configuration sources, and ensuring that both the Flask code and the Vue code reference the updated port, you should be able to resolve the inconsistency.
Feel free to provide more details if the issue persists!
Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?
No comments yet.
No comments yet.