Hello everyone, I’m facing a issue when config port for socket.io service. I use nginx as a proxy handle ssl and pass all request to frappe web app. The app will make a request https://domainabc.com:port/socket.io/ to create a connection to socket.io service, but value of port same as socketio_port in common_site_config.json and same port socket.io server start. I must expose the port from docker and the issue appear here, nginx and docker conflict handle the port. So, how to config the socket.io port in web app separate from docker port socket.io start?
In the Frappe front-end code, the socket host is determined by the following function:
get_host(port = 9000) {
let host = window.location.origin;
if (window.dev_server) {
let parts = host.split(":");
port = frappe.boot.socketio_port || port.toString() || "9000";
if (parts.length > 2) {
host = parts[0] + ":" + parts[1];
}
host = host + ":" + port;
}
return host + `/${frappe.boot.sitename}`;
}
The key part here is window.dev_server.
When you run bench start, this variable is set to 1, which makes Frappe behave as if it’s in dev mode — even if developer_mode is disabled in your site configuration.
Because of that, the frontend tries to connect directly to the socketio_port defined in common_site_config.json, e.g. https://domainabc.com:9000/socket.io/, causing a port conflict when Nginx and Docker both attempt to handle the same exposed port.
Solution:
Build and serve Frappe in production mode instead of using bench start.
In production mode, window.dev_server will not be set, and all socket requests will automatically go through Nginx’s reverse proxy rather than a separate exposed port.
You can do this by:
Building Frappe assets:
bench build
Starting the servers separately:
bench serve &
node apps/frappe/socketio.js &
or, as a workaround (which I used), running both in detached mode through a Makefile, without relying on bench start.
That way, Socket.IO and Frappe can run on separate ports internally, while Nginx proxies everything securely over HTTPS on port 443.