Can I use computer/host name instead of IP number in URL?

I have a flask app that I converted as a streamlit app. The streamlit app works fine. With my flask app, I can replace my IP # with my computer name in the URL and it works fine. However, with my streamlit app, if I replace the my IP # with computer name or host name, my streamlit app appears to be stuck with the message of “Connecting” showing up in top right and then in the body of the page it just keeps saying “Please wait…”

I prefer to be able to use my computer/host name instead of IP # since my IP # could change. Being able to use a computer name instead of IP # in the URL, my users (internal users at my company) would be able to access my steamlit app even if my IP # changes.

Therefore, it would be great if there is a way I can use computer/host name with streamlit somehow. Is this just a matter of setting up a configuration in the config.toml file? Or is this not possible with streamlit currently?

Darn, I missed the [browser] section in the config.toml file. I was just looking at the [server] section. Apparently, I just needed to do:
[browser]
serverAddress = ‘your_computer_name’

@pybokeh what do you mean by ‘your_computer_name’? Do you mean the IP address of your local server, or something else? Is there any chance you share with me your config.toml file? I cannot seem to find it on my Ubuntu. Thanks in advance for your help.

@mzeidhassan Hi. It is sort of like the human-readable version of your IP #. For example, instead of 10.44.16.32 it could be pybokeh.somecompany.domain.name.com

So with a web app, I can in theory share the URL as http://pybokeh:8501 instead of http://10.44.16.32:8501 with my coworkers.

I am on Windows 10 at work, but with a Google search, here is what I came up with for Ubuntu: https://helpdeskgeek.com/linux-tips/find-and-change-your-hostname-in-ubuntu/

Then in your config.toml fle, just add the lines:
[browser]
serverAddress = ‘your_computer_name’

and then the streamlit URL you can share (if they are within your network) would be:
http://your_computer_name:8501

EDIT: Per their docs, in the section “View all config options” for location of config.toml You can just create the config.toml file if it doesn’t exist.

2 Likes

I didn’t even consider sharing the app in the intranet using this approach and quite honestly I didn’t even know this would work but it did. I didn’t even have to update the config.toml file.
Thanks for such great insight @pybokeh.
GM

You’re welcome @gabe_maldonado ! I am researching if streamlit can be used in a company or industry setting which explains the scenarios I raise. So yes, having a intranet-aware Streamlit app would be so useful in a company setting. Wouldn’t surprise me if many people are not aware of this “trick” and perhaps unnecessarily hosted their streamlit app on a remote server and/or bothered their IT with server resources that were perhaps not needed.

Thank you @pybokeh for your help. I came across this useful page and it shows how to get the current configuration using streamlit config show and how to set it.

https://streamlit.io/docs/cli.html?highlight=streamlit%20config%20show#view-all-config-options

According to the latest changelog, we have this option now:

  • :gear: Use server.baseUrlPath config option to set Streamlit’s URL to something like http://domain.com/customPath .

Thanks for your support!

YW @mzeidhassan! FYI, if you are using custom base URL, you will have to add a trailing forward slash per this GitHub issue: https://github.com/streamlit/streamlit/issues/525 Looks like this bug will be fixed in the next version.

1 Like

How to assign my windows device name instead of IP address in URL

Depending on if company or personal laptop, but typically you would open the Windows “command prompt” and then issue the following command: ping localhost

Then you want to use the fully qualified domain name that comes after where it says “Pinging”…

Then you can use that instead of IP # which is typically dynamic, not static. Hope this helps.

  • Daniel
1 Like