VSCode Jupyter Server Connection Blocked - Unable to Maintain Session Without Restarting Kernel

I am using the following command to start a Jupyter server on my server:

jupyter notebook --ip='127.0.0.1' --port='6034' --no-browser --notebook-dir=~/code

I then set up port forwarding using SSH for port 6034 to connect to the Jupyter server via my laptop using Visual Studio Code (VSCode).

However, after a few hours, VSCode encounters an issue when sending requests and receives a “Forbidden” error:

[W 21:12:02.119 NotebookApp] Forbidden
[W 21:12:02.119 NotebookApp] 403 GET /api/kernels?1682802721867 (127.0.0.1) 1.660000ms referer=None

Restarting the kernel in VSCode temporarily resolves the problem, but I want to continue using my existing session without having to restart the kernel.