'localhost refused to connect when connecting through ssh

I want to use jupyter notebook on a remote server. I can connect to the remote server but when I open the jupyter notebook it says that the localhost refused to connect. The port number of the jupyter notebook is localhost:1237. how can I make it work?

It works when I use ssh 1237:localhost:1237 host@ip. but I don't want to use this as I want to keep the session running for long and the command line code only works on my windows cmd prompt so I can not use the screen I tried using this on the remote computer it says already in use.

My guess is I have to configure the port 1237 to localhost but that is only my guess



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source