OSError: ([Errno 98] Address already in use) in Streamlit Sharing

Hi guys,

I’m building an app which tries to authenticate a Google service via Oauth (credentials are in a JSON file).

Once the 1st credentials are uploaded, the script is meant to redirect the user to Google’s consent screen:

Instead, I have this error in Streamlit Sharing:

OSError: [Errno 98] Address already in use

Do you know if there’s an explanation for this?

It’s worth noting that this app works perfectly well on my local machine.

Here’s the app: https://share.streamlit.io/charlywargnier/streamlitgscconnectortests/main/GSCConnectMasterV2.py

And the code: https://github.com/CharlyWargnier/StreamlitGSCConnectorTests/blob/main/GSCConnectMasterV2.py

Also a screenshot of the full log trace:

Thanks in advance! :pray:

Charly

---- Update ----
I’ve deployed the same app/code in Heroku and I’ve got the same issue - see screenshot below:

This is fixed, thanks to @okld’s help! :raised_hands:

It was due to an incorrect setting from the library I was using. That setting was trying to spawn a local server in S4, which is not possible.

Charly

1 Like

Hi @Charly_Wargnier, I am actually facing this very issue when pushing to Heroku. I was wondering what setting you had to change? I am using the Google API to access a Google Sheet for my Streamlit app and I’m using the following Heroku buildpack to generate the credentials.json file needed in the project root. Can you explain what your steps were to troubleshoot this issue and get it working?

Error image for reference:

1 Like

Hi @ReactNinja,

I was using a Google API wrapper which gave me the possibility to switch to a localhost. I had to disable this option to fix the issue.

Check if there’s such a setting on the Google API you’re using.

Hope that helps

Best,
Charly

Hi @Charly_Wargnier,

Thanks for your response. I am using the google-api-python-client (2.0.2) which I believe allows me to authenticate the app and allows the spreadsheet data to be retrieved. I looked further into this and I think the conflict is when the following is called flow.run_local_server() as it defaults to the following parameters: host=“localhost”, port=8080. I have tried changing the port to something else like 8888 but the issue still persists. I am not sure what I could change the host to as I am deploying it on Heroku. How did you stop this from spawning the local instance? I do believe this is needed for the user (me) to login and authenticate the app.

Hi Charly! I encounter the same issue with Josh Carty Search Console Wrapper.
Could you please specify what setting have you modified to resolve this?

Thank you in advance!

Salut Alek! It’s great to see you on the forum! :raised_hands:

As far as I can remember, it was something to do with the flow parameter in Josh’s wrapper.

Try to play around with the different options offered, I’m pretty sure this should get rid of your issue :slight_smile:

Let me know how that goes!

Best,
Charly

I got my streamlit app working locally. This is small app that uses Oauth to authenticate a user to spotify and get their top 10 songs and artists. Streamlit (spotify-monthly-wrapped.streamlit.app) . When I deployed it on to the community cloud I got the "OSError: [Errno 98] Address already in use " error.

I have loaded the credentials but seems like Oath is not fully working as it is not redirecting me to spotify to log in. The code for this is svarghese1998/spotify-monthly-wrapped at testing_app_deployment (github.com). Would really appricate any help.