Address already in use Port 8912 is in use by another program while executing app.run

Hello,

I have a dash ag grid table that is hosted by a mercury app MLJAR Mercury

When I run the app and the grid loads I am receiving an error:

`TypeError: object of type ‘NoneType’ has no len()
Traceback (most recent call last):
File “/opt/conda/lib/python3.10/site-packages/werkzeug/serving.py”, line 710, in init
self.server_bind()
File “/opt/conda/lib/python3.10/http/server.py”, line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File “/opt/conda/lib/python3.10/socketserver.py”, line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/opt/conda/lib/python3.10/site-packages/IPython/core/interactiveshell.py”, line 3457, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File “”, line 51, in
app.run(debug=False, port=8912)
File “/opt/conda/lib/python3.10/site-packages/dash/dash.py”, line 1996, in run
jupyter_dash.run_app(
File “/opt/conda/lib/python3.10/site-packages/dash/_jupyter.py”, line 329, in run_app
server = make_server(host, port, app.server, threaded=True, processes=0)
File “/opt/conda/lib/python3.10/site-packages/werkzeug/serving.py”, line 877, in make_server
return ThreadedWSGIServer(
File “/opt/conda/lib/python3.10/site-packages/werkzeug/serving.py”, line 733, in init
sys.exit(1)
SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py”, line 1101, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File “/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py”, line 248, in wrapped
return f(*args, **kwargs)
File “/opt/conda/lib/python3.10/site-packages/IPython/core/ultratb.py”, line 281, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File “/opt/conda/lib/python3.10/inspect.py”, line 1662, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: ‘tuple’ object has no attribute ‘tb_frame’
Address already in use
Port 8912 is in use by another program. Either identify and stop that program, or start the server with a different port.`

Hello @gmouawad,

Could you try using a different port?

Is it possible that you arent checking to see this:

if __name__ == '__main__':
    app.run(port='8912')

Or whatever.

I have modified lots of ports, 80, 8080, 8090 etc nothing is working

It sounds like you need to test like I mentioned above.

app.run(debug=False,port=8080) I am doing this

@jinnyzor exactly what you mentioned but different port

You need to have an if clause, otherwise the app will run twice.

it is included in if clause:

if __name__ == "__main__":
    if loaded == True and historyYes == True and selected == True:
        #rPort = random.randrange(8000, 9000)
        app.run(debug=False,port=8080)

Interesting.

Are you following a guide to host your site?

I am including the dash ag grid app into a mljar mercury notebook