question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What should be the port value for working on the production server?

See original GitHub issue

When developing on a local machine I used standart code to authorize and work with Google disk

creds = None
cred = os.path.join(settings.BASE_DIR, 'credentials.json')
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
    with open('token.pickle', 'rb') as token:
        creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
    if creds and creds.expired and creds.refresh_token:
        creds.refresh(Request())
    else:
        flow = InstalledAppFlow.from_client_secrets_file(
            cred, SCOPES)
        creds = flow.run_local_server(port=8080)
    # Save the credentials for the next run
    with open('token.pickle', 'wb') as token:
        pickle.dump(creds, token)

I use 8080 as the port parameter value. This works. When deploying a project on a production server, I get a message port is already in use.

Server: Ubuntu 18.04, Nginx, uwsgi, Django

I’ve changed the port to 5000, everything works on the local machine. I tried to run it on a production server and got a 504 error. I checked the uwsgi log and saw that the end of the file contains a link to authorization.

Screenshot from 2019-09-12 16-16-08

On the local machine, this link automatically opens in a new window to log on to the account. If try to run the production server again, I will get the [Errno 98] Address already in use error and this error is saved until reboot uwsgi. After the reboot, everything repeats itself again.

I’ve tried many different port meanings, the same problem with everyone. I think the problem here is not in the specific meaning. After restart uwsgi there is an attempt of authorization (i.e. the value of the port is accepted) but the redirection by reference to OAuth2 does not occur. And it’s quite strange that when try again, the error [Errno 98] Address already in use

What values should I use?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
Lepiloffcommented, Sep 13, 2019

@busunkim96 thank you for answering. Yes, I use web server application. Google API documentation in some places not very clear. Now I know that run_local_server uses only for locall projects. It is very strange that there are no good examples on the Internet for using Django and Google API for my purposes. I will try to deal with this problem

0reactions
dhwaj1902commented, Jun 12, 2022

Hey @Lepiloff can you help me regarding this, how do you solve the problem you are facing, like how do you implement the code for web server using python. I am not able to get any relatable answer on the entire internet. Actually I want to send mails to users using gmail api. And it is running fine on localhost( using desktop application), but when I moved this to my server it started showing me the error [Errno 98] Address already in use. But the port I am activating for the authentication is an empty port on my server.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What should be the port value for working on the production ...
1 Answer 1 ... Try netstat to see what ports are in use. ... Any of the ports returned will give you the...
Read more >
What are port numbers and how do they work? - TechTarget
A port number is a way to identify a specific process to which an internet or other network message is to be forwarded...
Read more >
Changing the NICE DCV Server TCP/UDP ports and listen ...
Open the web-port parameter. For Value data, enter the new TCP port number. If you don't configure this parameter, the NICE DCV server...
Read more >
Securing a Production Environment for Oracle WebLogic Server
The SSL/TLS listen port is enabled by default. The default port value is 7002. Security or configuration auditing is disabled by default. Security...
Read more >
Production Server - an overview | ScienceDirect Topics
I have been in environments where production servers could not have software ... In the case of an HP EVA storage array, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found