SaferComputing.com

Reference · Local AI servers

Gradio port 7860 and share links: check server_name, share=True and auth

Check whether a Gradio app on port 7860 listens on 0.0.0.0 through server_name or GRADIO_SERVER_NAME, whether share=True opened a public gradio.live link, and how to add auth or close both.

Published
Updated
Last checked
Applies to
Gradio 6 apps and web UIs built on Gradio, such as the AUTOMATIC1111 Stable Diffusion web UI, on Windows 11, macOS and Linux
Technical specification
Target artifactThe web page and API of a Gradio app on TCP port 7860, with its address set by server_name or GRADIO_SERVER_NAME, and an optional public link set by share=True.
Default behaviourListens on 127.0.0.1, on port 7860 or the next free port after it. server_name="0.0.0.0" opens it to the network. share=True, the default in Google Colab, publishes it at a public https://xxxxx.gradio.live address through Gradio's share server. There is no sign-in unless the app sets auth.
Safe stateListening on 127.0.0.1; no share=True, GRADIO_SHARE=True or --share unless you mean to publish the app; auth set on anything other people can reach; no GRADIO_SERVER_NAME=0.0.0.0 left in the environment or a launcher.
Check on Linuxsudo ss -tlnp | grep -E ':78[6-9][0-9]\b'
Check on WindowsGet-NetTCPConnection -State Listen -LocalPort 7860, 7861, 7862 -ErrorAction SilentlyContinue | Select-Object LocalAddress, LocalPort, OwningProcess
Check on macOSsudo lsof -nP -iTCP -sTCP:LISTEN | grep -E ':78[6-9][0-9] '
Check from another devicecurl --max-time 5 -I http://SERVER_IP:7860/
Fixremove server_name="0.0.0.0" and share=True from launch(), and unset GRADIO_SERVER_NAME and GRADIO_SHARE
Fix in apps built on Gradioremove --listen and --share from the launch options, such as COMMANDLINE_ARGS in webui-user.bat or webui-user.sh

Read the result

Gradio apps run inside Python, so the program column shows python or python.exe rather than the app's name.

Listening addressWho can reach the app
127.0.0.1:7860This computer only
0.0.0.0:7860, *:7860 or [::]:7860Every network interface: Wi-Fi, Ethernet and any VPN

A second app on the same computer takes 7861, the next one 7862, and so on. From another device, any HTTP status line means the app answers from there; "Connection refused" or a timeout means it does not. In Windows PowerShell, type curl.exe rather than curl.

The listening address does not show a share link. A share link reaches the app through an outgoing tunnel, so check for it separately, below.

share=True in launch() creates a public address such as https://a23dsf231adb.gradio.live. Anyone who has it can use the app from their browser, while the model and all computation keep running on your computer. Gradio's share server does not host the app: an FRP client on your computer opens a TLS tunnel to the share server, which passes visitors through to your app. The link therefore works only while the app runs.

  • How long it lasts: Gradio's launch message and its guide to sharing an app say one week, and an issue in Gradio's repository calls that limit best effort; its guide to share links still describes a 72-hour timeout on the shared server. Do not rely on either: stop the app to end access.
  • Where it shows: the public address appears in the app's output when it starts. Search the app's output or log for gradio.live.
  • Google Colab: share defaults to True there, and share=False is not supported where localhost is not reachable, as in Colab.
  • Turned on without code changes: GRADIO_SHARE=True in the environment, or a --share option in a web UI built on Gradio.

While a link is open, Gradio's FRP client runs as a program of its own. Gradio's guide shows one named frpc_darwin_arm64_v0.3; the name changes with the system.

Linux or macOS terminal
ps -ef | grep -i [f]rpc
Windows PowerShell
Get-Process -Name frpc* -ErrorAction SilentlyContinue

Any result means an FRP tunnel is running, from Gradio or another program. Find the app it belongs to and stop it.

Note Antivirus warnings about the FRP client

Gradio's guide says some antivirus programs, notably Windows Defender, block the download of the FRP client, and that you may need to allow the file to use share links. If you did not mean to publish the app, leave it blocked and remove the share setting.

Keep it on 127.0.0.1

Your own Gradio script

Leave server_name out, or set it to the loopback address, and leave share off:

Python, in the app's script
demo.launch(server_name="127.0.0.1", share=False)

The same settings can come from the GRADIO_SERVER_NAME and GRADIO_SHARE environment variables, so check that neither is set where the app starts:

Linux or macOS terminal
env | grep GRADIO_
Windows PowerShell
[Environment]::GetEnvironmentVariable('GRADIO_SERVER_NAME', 'User')
[Environment]::GetEnvironmentVariable('GRADIO_SERVER_NAME', 'Machine')
[Environment]::GetEnvironmentVariable('GRADIO_SHARE', 'User')
[Environment]::GetEnvironmentVariable('GRADIO_SHARE', 'Machine')
Web UIs built on Gradio

Apps such as the AUTOMATIC1111 Stable Diffusion web UI pass their own options to Gradio. In that web UI:

OptionWhat it does
--listenLaunches Gradio with 0.0.0.0 as the server name, so it answers network requests
--shareTurns on share=True and a public gradio.live link
--ngrokPublishes it through ngrok, as an alternative to --share
--portChanges the port, 7860 by default
--gradio-authRequires a sign-in, written as username:password
--api and --api-authTurn on the API, and set a separate sign-in for it

Its options live in COMMANDLINE_ARGS, set in webui-user.bat on Windows or webui-user.sh on Linux. Remove --listen, --share and --ngrok there unless you mean to publish it. In other Gradio-based apps, check the launch scripts for options that set the server name or turn on sharing.

Docker

Publish the container's port on the loopback address, for example -p 127.0.0.1:7860:7860 instead of -p 7860:7860, and check the host side with docker ps --format 'table {{.Names}}\t{{.Ports}}'. Ports published by Docker bypass UFW; see Docker published ports.

Add a sign-in

auth takes a username and password, a list of username and password pairs, or a function that checks them and returns True for a valid sign-in. auth_message adds a message to the sign-in page.

Python, in the app's script
demo.launch(auth=("admin", "A-LONG-UNIQUE-PASSWORD"))

Use it on any app other people can reach, including through a share link, and keep the password out of code you share.

Files are part of the exposure too. By default, most files on the computer are not accessible to the app's users, but every folder listed in allowed_paths or GRADIO_ALLOWED_PATHS is, with all its subfolders. blocked_paths takes precedence over both.

Troubleshooting

It still listens on 0.0.0.0
  • GRADIO_SERVER_NAME=0.0.0.0 is set in the environment, a launcher script or a service definition.
  • A web UI built on Gradio has --listen in its options.
  • The app was not restarted after the change.
The app listens on 127.0.0.1, but someone outside reached it

A share link or another tunnel carries the traffic. Search the app's output for gradio.live, and run the FRP client check above.

Sources