Terminal and localhost

How come if I'm running a localhost in the terminal and click Cmd-K it clears everything as well as blocking the localhost and not giving any access to it?


Thanks, Dan

MacBook Pro 15″, macOS 12.4

Posted on Jun 18, 2023 5:29 AM

Reply
8 replies

Jun 18, 2023 9:40 AM in response to yachv_1998

yachv_1998 wrote:

I would have the localhost open on terminal and you will be able to see the address, and then I would click cmd k and when I click on the local host tab on the browser it wont open.


⌘ T opens a new tab in Terminal app.


All newly-opened tabs are local sessions (all are on localhost), unless something within the shell customizations on the local Mac issues an ssh command, or a telnet command if that’s been installed, or similar connection, and a connection is created from the Mac into some other server, or into some guest when a VM is installed, or similar.


The shell prompt you are likely seeing from the shell session is determined by your local customization, or by the default PS1 setting in bash or the default PROMPT setting in zsh, or whatever other shell you are using, when no local customization is configured. The default prompt string for some shells can pull in some data from the network setup, which is likely why you’re referencing localhost here.

Jun 18, 2023 10:18 AM in response to yachv_1998

yachv_1998 wrote:

thanks you, that makes sense! how can i access the local host file? because it has dissapeared...


There is no “local host” file, though there is /etc/hosts. All files on your Mac are on the local host.


Guessing at your goal: download BBEdit (basic functions are free), and use that to open and change the /etc/hosts file.


BBEdit allows access to the text file contents of /etc/hosts from the Mac graphical interface.


The /etc/hosts file is occasionally used for testing a website or such, as a lumpy way of naming the hosts on the local network, as a problematic means of ad blocking, a few other odd and unusual tasks, and for installing what can be malware and some other Really Sketchy things.


The format of the lines included in and added to that file are important. Follow the included doc.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal and localhost

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.