How to reopen a terminal window that was running a port or how to get port logs to show on current terminal window?

When you start running a port (ex: 8000) on a terminal, this terminal will present logs that are useful for debugging purposes such as print() statements.
Once this terminal is closed, you can easily open a new terminal or a split terminal. However, non of those will show the useful log information from previously closed terminal window.

My question is how to reopen the terminal or how to get the logs from running port to show on current terminal?

What do you mean by ‘start running a port’? Do you mean start a binary that listens on a port? Are you running some specific command or something?

I guess I meant to say runserver on the port (correct me if I am wrong).

For example:
1- go to the terminal
2- type: python3 manage.py runserver

You can use tmux for you use case.
Might need to install it first: sudo apt install tmux.

For example: tmux new-session -d -s server 'python3 manage.py runserver'

Later you can attach back to this terminal session from any other terminal like so: tmux attach -t server

Hope this helps!

1 Like

Thanks for the reply Axon,

I typed ‘sudo apt install tmux’ and got error:
“E: Unable to locate package tmux”

I am very beginner. Thanks for your patience.

I think you need to run sudo apt-get update first.
This seems to work fine under gitpod.io workspaces.

Let me know if it’s still not working though.

1 Like

You need sudo apt update or sudo apt-get update to fetch the latest package lists.

1 Like

It worked:
1- sudo apt-get update
2- sudo apt install tmux
3- tmux new-session -d -s server ‘python3 manage.py runserver’
4- tmux attach -t server

3 Likes