1
1
When you launch Automatic1111’s Stable Diffusion WebUI, often referred to in community discussions as “forge” due to its performance-enhancing forks like SD Forge, it defaults to running a local web server on port **7860**. This means after starting the application, you access the graphical interface by pointing your web browser to `http://127.0.0.1:7860` or `http://localhost:7860`. This specific port is simply a convention chosen by the developers; it’s not a mandatory standard, but it has become the universally recognized default for this particular application. You will see this port number printed directly in the terminal or command prompt window immediately upon successful launch, confirming the server is active and waiting for your connection.
However, the port is not fixed. You have full control to change it if needed, which is a common requirement when port 7860 is already occupied by another service or for organizational purposes. This is done by adding a command-line argument when you start the web UI. For example, on Windows using the `webui-user.bat` file, or on Linux/macOS using the `webui.sh` script, you would edit the file to include `–port 8080` or any other unused port number after the existing command. Alternatively, you can set an environment variable named `GRADIO_SERVER_PORT` to your desired number before launching. This flexibility ensures the tool can coexist with other development servers or applications you might be running simultaneously.
Understanding why you might need to change the port is practical. A frequent scenario is having another local web application, such as a different AI tool, a local database dashboard, or a development server, already bound to port 7860. The system will refuse to start the WebUI on that occupied port, resulting in an error message. By scanning your system with a command like `netstat -ano | findstr :7860` on Windows or `lsof -i :7860` on macOS/Linux, you can identify the conflicting process. Choosing a new, high-numbered port like 7861, 8080, or 9000 avoids these conflicts and follows the common practice for ephemeral ports. Forgetting to update your browser bookmark to the new port is a simple but common user error after making this change.
Beyond local use, the port number is critical for remote access. If you configure the WebUI to listen on all network interfaces (`–listen` flag) instead of just the localhost, other devices on your local network can connect to your machine’s IP address followed by the port, such as `http://192.168.1.50:7860`. Here, using a standard, non-privileged port (above 1024) is essential because firewalls and network routers are less likely to block these ports by default. For secure remote access over the internet, this port becomes the target for port forwarding on your router, making it a key piece of information for your network configuration. Always pair remote access with strong passwords and, ideally, a VPN for security.
Troubleshooting connection issues often circles back to the port. If the browser shows “Connection Refused,” the WebUI process may have crashed or failed to start, so check the terminal for error logs. A “Timeout” error suggests a firewall on your computer or network is blocking the port. On Windows, you may need to allow the Python executable through the Windows Defender Firewall for both Private and Public networks. On macOS, the built-in firewall or a third-party security suite might require similar permission. Verifying the port is actually listening with the `netstat` or `ss` command is a definitive first step in diagnosis.
Security considerations around the port are paramount, especially when enabling remote access. The Automatic1111 WebUI does not have built-in, robust authentication by default in its basic form. Leaving it open on a port accessible to your local network means anyone on that network could potentially use your GPU and generate images. Mitigation involves using the `–gradio-auth` flag to set a username and password, or more securely, placing the entire interface behind a reverse proxy like Nginx or Apache with HTTP authentication. Furthermore, never expose the default port directly to the public internet without a reverse proxy, SSL/TLS encryption (HTTPS), and rigorous firewall rules, as it would be an open invitation for misuse.
For users running SD Forge, which is a performance-optimized fork, the port behavior remains identical because it uses the same underlying Gradio web framework. The core experience and configuration options, including port management, are preserved. Any modifications for performance in SD Forge happen at the backend, not in the basic network interface setup. Therefore, all advice about changing ports, securing access, and troubleshooting applies equally to both the original Automatic1111 repository and its popular forks like SD Forge or ComfyUI’s web servers, which also default to 7860 or similar ports.
In practice, the most actionable information is to always note the port displayed at startup and to proactively manage it. If you run multiple AI tools, consider establishing a personal convention, like reserving 7860 for Stable Diffusion, 7861 for ComfyUI, and 8080 for a local LLM interface. Document this in a simple text file. When installing updates, remember that update scripts might reset configuration files, so you may need to re-add your custom `–port` argument to the launch script. Keeping a backup of your modified `webui-user.bat` or `.sh` file prevents this minor but frustrating hiccup.
Ultimately, the port is a simple but fundamental detail for the Stable Diffusion WebUI ecosystem. Its default of 7860 is a helpful starting point, but the ability to change it is a necessary feature for real-world usage. Mastering this small piece of configuration—knowing how to check it, change it, and secure it—removes a common barrier to a smooth and safe local AI image generation experience. The core takeaway is to treat the port number as a key piece of your local server’s address, verify it upon each launch, and adjust it deliberately to suit your specific workflow and security needs.