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.

3 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.

2 Likes

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!

3 Likes

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.

3 Likes

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

1 Like

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

thanks man, very handy!

You’re welcome! Wow this post is more than a year old. Glad it is still useful to others. But yeah, this basic networking knowledge is so handy.

I landed on this after some searching and I must say this is an excellent post. Very helpful :slight_smile:

I am, however, unsure what I am doing wrong but I followed what pybokeh mentioned but still does not appear to work for me :frowning:

Thanks in advance for the help.

Below is my config.toml

[theme]
base=“light”
primaryColor="#2da1d4"
secondaryBackgroundColor="#d0d8dc"

[browser]
serverAddress=“supporttoolslocal”

Hello @pybokeh and all;
I am currently preparing a streamlit app that allows both training and inference of a model. I am looking for something that can give me the server address of the app in the python script itself. The reason behind this is that I am using streamlit as a handy interface. However, when the app is deployed, I don’t want to show the training functions, but rather only the inference. On the other hand, if the app is started locally, the training functions can show.
Can anyone help me if there is a python function to call that would return e.g “localhost” when the app will start locally and would return some URL of the deployed app when the app is indeed deployed and started from some web address?

Kindly where can I find or create the config.toml
Os Ubuntu.

your post helped a lot, i changed the baseUrlPath = “department_name”, and the server address to my computer name like this serverAddress = “computer_name”.

Now everyone can see it under http://computer_name:port/department_name

1 Like

Sorry but I don’t get what I’m doing wrong, would appreciate the help : )

I updated serverAddress = “bart” but the url doesn’t work (http://bart:8501/), I just get bart ’s server IP address could not be found.

however, using the computer’s IPv4 Address works fine. http://XX.X.XXX.XXX:8501/

I’m using windows and on a VPN.

hey did you ever solve this, I’m having the same issue, after updating serverAddress the new url doesn’t work, only the IP4Address works