Panel serve --port <portnumber> no longer uses the port number I specify

For a Panel app that I deploy on an Ubuntu server (and test on an Ubuntu laptop), I’ve been using the following for nearly a year:

panel serve --port `portnumber` myapp.ipynb

And the app is then available at http://localhost:portnumber/mynotebookapp. My environment was pinned to panel <1 and bokeh <3. I recently updated my environment to panel 1.3.8 and bokeh 3.3.4, and the port number I specify is not respected; the app launches just fine and works fine (after I fixed it to work with these packages versions), but using a port number picked by the server, with a run-time message like this: Launching server at http://localhost:36103. This is despite the log file having this entry (when launched with --port 5100): Bokeh app running at: http://localhost:5100/myapp. I can’t find anything in the documentation that suggests the usual --port argument would not behave as expected.

BTW, another change is that the app is no longer available at a url that includes the notebook filename, like this: http://localhost:36103/myapp.

Any insight would be appreciated. Thanks.

I have the latest Panel and it works as expected. Can you try upgrading?

Thanks. I created a new conda environment (using mamba and packages from conda-forge) where I removed version pinning on bokeh and panel; I got bokeh 3.4.1 and panel 1.4.2. The app still works, fortunately – that’s a big relief! The panel serve --port behavior is now a step forward, but it’s still doing the port switching. Here are the initial run-time log lines after issuing the command $ panel serve --port 43100 ./myapp.ipynb:

2024-05-02 23:34:32,177 Starting Bokeh server version 3.4.1 (running on Tornado 6.4)
2024-05-02 23:34:32,178 User authentication hooks NOT provided (default user enabled)
2024-05-02 23:34:32,180 Bokeh app running at: http://localhost:43100/myapp
2024-05-02 23:34:32,180 Starting Bokeh server with process id: 1406057

2024-05-02 23:34:45,641 Starting Bokeh server version 3.4.1 (running on Tornado 6.4)
2024-05-02 23:34:45,641 User authentication hooks NOT provided (default user enabled)
Launching server at http://localhost:38449

So first there’s the line Bokeh app running at: http://localhost:43100/myapp that uses the port number I specify. But then the last line, Launching server at http://localhost:38449, presents a different port number. When I enter http://localhost:43100/myapp on the browser, the app does run on that address, but a second tab is launched with the other address, http://localhost:38449. This is weird!

I think you are using .show() instead of .serveable() in your code.

1 Like

You’re right :man_facepalming: !! I do use .serveable(), but I had inadvertently left a .show() in my code, that I was using during development.

Thanks so much.

1 Like