What should be the port value for working on the production server?
See original GitHub issueWhen 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.
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:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
@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 problemHey @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.