Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default of browser.serverAddress is not actually "localhost" #8629

Closed
3 tasks done
wyattscarpenter opened this issue May 7, 2024 · 8 comments · Fixed by #8647
Closed
3 tasks done

default of browser.serverAddress is not actually "localhost" #8629

wyattscarpenter opened this issue May 7, 2024 · 8 comments · Fixed by #8647
Labels
feature:config Related to config settings type:docs Requests for changes to docs (will be rerouted to docs repo)

Comments

@wyattscarpenter
Copy link

wyattscarpenter commented May 7, 2024

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

https://docs.streamlit.io/develop/api-reference/configuration/config.toml#browser says the default of serverAddress is "localhost". However, this can't be true, because if I streamlit run a file without

[browser]
serverAddress = "localhost"

in the config.toml

I get something like the following:

  You can now view your Streamlit app in your browser.

  Network URL: http://[some private IPv4 address]:8501
  External URL: http://[some public IPv4 address]:8501

And when I add the lines to the config.toml I get

  You can now view your Streamlit app in your browser.

  URL: http://localhost:8501

instead. (Which is the desired behavior in my case.)

localhost:8501 works to access the application either way.

This is either a documentation issue or a true bug.

@wyattscarpenter wyattscarpenter added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels May 7, 2024
Copy link

github-actions bot commented May 7, 2024

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@raethlein
Copy link
Collaborator

Hey @wyattscarpenter, I have just tried to reproduce it on my M1 Mac, but there it behaves correctly and I correctly see

You can now view your Streamlit app in your browser.

Local URL: http://localhost:3000
Network URL: http://192.168.0.200:3000

The log lines seem to come from this method where also the IP address is determined; when no respective config options are set, it seems to jump into net_util.get_internal_ip() which seems to determine the IP address via the socket package for the log. The bound address itself should depend on tornado's listen method which we call here.

I don't have anything set in the config.toml file. Are you connected to a VPN or run the app in a virtual machine or container or so? And are you able to connect to the app via localhost despite the log showing a different address?

@wyattscarpenter
Copy link
Author

@raethlein interesting! I'm on Windows 10 (and the same thing happens in WSL on that machine). As far as I know I'm not in a VPN, VM, or container. I'm using streamlit 1.34.0 but it's been like this since I can remember. I can connect via localhost.

Looking at the method you cite, the cause is straightforward: I have server.headless set to true in the config as well. So the elif config.get_option("server.headless") triggers. Removing that makes my ouput

  Local URL: http://localhost:8501
  Network URL: http://10.150.8.250:8501

as well.

@raethlein
Copy link
Collaborator

Great!
Do you have a suggestion of how we could improve the docs to make this more clear or is it good as is then?

@raethlein raethlein added type:docs Requests for changes to docs (will be rerouted to docs repo) area:backend and removed status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working area:backend labels May 7, 2024
@LukasMasuch LukasMasuch added the feature:config Related to config settings label May 7, 2024
@vdonato
Copy link
Collaborator

vdonato commented May 8, 2024

Going to transfer this issue into the docs repo so that it's in a more correct location

(Huh, looks like I can't for some reason 😕)

@wyattscarpenter
Copy link
Author

I'm not sure whether or not it's a docs issue. I don't know why the server.headless setting overrides the browser.serverAddress setting. Maybe it's a good reason, since the behavior seems intentional. I could imagine that for some reason a headless server might need to output the things it currently does. But maybe not.

Assuming the behavior is desirable: add note (in both places?) that server.headless overrides the browser.serverAddress setting.

If the behavior isn't desirable: make it not do that, I suppose.

@raethlein
Copy link
Collaborator

good points, thanks 🙂 I guess the behavior is desirable since you can also connect via localhost and that the output prints are misleading. So looking at the lines I guess that localhost should be printed out additionally when the mode is headless.

@wyattscarpenter
Copy link
Author

That seems like a pretty good solution to me.

raethlein added a commit that referenced this issue May 14, 2024
## Describe your changes

Closes #8629

When Streamlit is started via `server.headless=true`, the address output
does not contain `localhost`, although the server can still be reached
via `localhost`. The `headless` mode just defines whether a browser is
started, not what the address binding is. So, the idea is to show
`localhost` also in case when `server.headless=true` is set.


## GitHub Issue Link (if applicable)

## Testing Plan

- Explanation of why no additional tests are needed
- Unit Tests (JS and/or Python)
- E2E Tests
- Any manual testing needed?

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:config Related to config settings type:docs Requests for changes to docs (will be rerouted to docs repo)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants