Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IOError("Port 8080 not free on '127.0.0.1'",)

Hi, I am a starter for fitbit and trying to use the API.

 

I am trying to get the access token and refresh token by running the script below

python-fitbit/gather_keys_oauth2.py <OAuth 2.0 Client ID> <Client Secret>

 

but keep getting the error that says "Port 8080 not free on '127.0.0.1'"

 

The full text of error are like follows,

 

[20/Jan/2021:00:44:00] ENGINE Listening for SIGHUP.

[20/Jan/2021:00:44:00] ENGINE Listening for SIGTERM.

[20/Jan/2021:00:44:00] ENGINE Listening for SIGUSR1.

[20/Jan/2021:00:44:00] ENGINE Bus STARTING

CherryPy Checker:

The Application mounted at '' has an empty config.

 

[20/Jan/2021:00:44:00] ENGINE Started monitor thread '_TimeoutMonitor'.

[20/Jan/2021:00:44:00] ENGINE Started monitor thread 'Autoreloader'.

[20/Jan/2021:00:44:05] ENGINE Error in 'start' listener <bound method Server.start of <cherrypy._cpserver.Server object at 0x10cde9450>>

Traceback (most recent call last):

  File "/Users/sju04312/Library/Python/2.7/lib/python/site-packages/cherrypy/process/wspbus.py", line 205, in publish

    output.append(listener(*args, **kwargs))

  File "/Users/sju04312/Library/Python/2.7/lib/python/site-packages/cherrypy/_cpserver.py", line 168, in start

    ServerAdapter.start(self)

  File "/Users/sju04312/Library/Python/2.7/lib/python/site-packages/cherrypy/process/servers.py", line 170, in start

    wait_for_free_port(*self.bind_addr)

  File "/Users/sju04312/Library/Python/2.7/lib/python/site-packages/cherrypy/process/servers.py", line 439, in wait_for_free_port

    raise IOError("Port %r not free on %r" % (port, host))

IOError: Port 8080 not free on '127.0.0.1'

 

[20/Jan/2021:00:44:05] ENGINE Shutting down due to error in start listener:

Traceback (most recent call last):

  File "/Users/sju04312/Library/Python/2.7/lib/python/site-packages/cherrypy/process/wspbus.py", line 243, in start

    self.publish('start')

  File "/Users/sju04312/Library/Python/2.7/lib/python/site-packages/cherrypy/process/wspbus.py", line 223, in publish

    raise exc

ChannelFailures: IOError("Port 8080 not free on '127.0.0.1'",)

 

[20/Jan/2021:00:44:05] ENGINE Bus STOPPING

[20/Jan/2021:00:44:05] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) already shut down

[20/Jan/2021:00:44:05] ENGINE Stopped thread '_TimeoutMonitor'.

[20/Jan/2021:00:44:05] ENGINE Stopped thread 'Autoreloader'.

[20/Jan/2021:00:44:05] ENGINE Bus STOPPED

[20/Jan/2021:00:44:05] ENGINE Bus EXITING

[20/Jan/2021:00:44:05] ENGINE Bus EXITED

 

 

Please can someone help me with this issue?

 

I have found a topic similar to my problem but I cannot fix the problem as they did in 

https://community.fitbit.com/t5/Web-API-Development/How-to-use-API/m-p/1132430/highlight/true#M4317

 

I already have set the redirect uri in my app and in gather_keys_oauth2.py as "http://127.0.0.1:8080/"

 

I hope I can find what is causing this problem.

 

Thank you for reading my issue.

Best regards to everyone. 

 

Best Answer
0 Votes
2 REPLIES 2

Hi @jung123,

 

Is your application production or a testing environment? I ask because I can see that you're using localhost as your callback url. Using localhost is fine for testing purposes, but won't work in production. Localhost isn't accessible externally, so you'll need to provide a valid URL to redirect Fitbit users back to after authorization.

 

Have you checked our Community Resources for Python sample code?

 

I hope this helps. Let me know if you have any additional questions.

Best Answer
0 Votes

Hi @JohnFitbit , Thanks for the reply!

 

I have fixed the problem by changing the port number.

 

It seems that my computer was already doing some operation on port 8080.

 

I was only testing for now, but I plan to change the redirect URL when I use it as application production

 

Thank you for your help!

 

Best Answer