What is the proper way to terminate the Vue CLI 3 development server? - macos

I have just started to use Vue CLI 3 for a project and it looks like I am not terminating a development session correctly. Like the docs suggests I start a development session with:
npm run serve
Which gives me the port to work on:
App running at:
- Local: http://localhost:8087/
- Network: http://192.168.0.100:8087/
When I'm done working on my project I hit Ctrl-Z and I have my command line back. Yay!
But this leaves something still listening on the port:
lsof -i TCP:8087
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 58122 jannie 14u IPv4 0xc7ce0b7d644a357d 0t0 TCP *:8087 (LISTEN)
How can I terminate the development server gracefully so that it frees the port when I am done?

Try using Ctrl-C instead. It allows the application to gracefully shut down.

Related

How to check if Cloud Pub/Sub emulator is up and running?

I have GC functions which I develop and test locally by using Cloud Pub/Sub emulator.
I want to be able to check from within Go code if Cloud Pub/Sub emulator is up and running. If not, I would like to inform a developer that he/she should start emulator before he/she execute code locally.
When the emulator starts I noticed a line
INFO: Server started, listening on 8085
Maybe I can check if port is available or similar.
I guess you have used this command:
gcloud beta emulators pubsub start
And you got the following output:
[pubsub] This is the Google Pub/Sub fake.
[pubsub] Implementation may be incomplete or differ from the real system.
[pubsub]
[pubsub] INFO: IAM integration is disabled. IAM policy methods and ACL checks are not supported
[pubsub]
[pubsub] INFO: Applied Java 7 long hostname workaround.
[pubsub]
[pubsub] INFO: Server started, listening on 8085
If you take a look at the second INFO message you'll notice that the process name will be JAVA. Now you can run this command:
sudo lsof -i -P -n
Getting all the listening ports and applications, the output should be something like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
XXXX
XXXX
java XXX XXX XX IPv4 XXX 0t0 TCP 127.0.0.1:8085 (LISTEN)
Alternatively you can modify the previous command to show only what is happening on the desired port:
sudo lsof -i -P -n | grep 8085

Killing an unknown self restarting server on port 80 Mac OSX

I have a server running on port 80, but I do not know what it is or where it came from. When I run
sudo lsof -i :80 | grep LISTEN
I get
httpd 80 root 5u IPv6 0x91f5a9de62859cfd 0t0 TCP *:http (LISTEN)
httpd 694 _www 5u IPv6 0x91f5a9de62859cfd 0t0 TCP *:http (LISTEN)
I have tried to enter get the process name using the PID, but all I ever get in return is "httpd" or "FOREGROUND".
When I kill the PID, the process simply restarts with a new PID. I assume I will have to stop it at launch.
How can I stop this server from running at startup?
If it helps any, I am trying to free up port 80 to use the apache server on MAMP.
This is just a guess, but it might be the built-in version of apache, being launched (& restarted) by launchd (OS X's daemon manager). It's disabled by default, but might've gotten enabled somehow. You can try disabling it with:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
If that doesn't do it (it'll say something like "Could not find specified service"), you can check to see if it's some other launch daemon item by looking for the PID of the master process (the one running as root, not _www):
sudo launchctl list | grep <masterPID>
That won't necessarily tell you exactly what's going on, but might point you in the right direction.
Like Gordon suggested, that's the built-in version of the Apache web server.
You can stop it with
sudo apachectl stop
btw, the configuration for this webserver can be found in the /etc/apache2/httpd.conf directory.
This happens to me a lot.
As #Gordon Davisson explains it is most likely the launchdeamon process conflicting with the service you have set up.
Definitely stop the apachetl server.
sudo apachetl -k stop
Try to find all the httpd process, they should be the last ones
sudo lsof -i :80 // without grep
Then get the first process (most likely in the 1000s) should also be the lowest one.
sudo kill <firstHttpdPID>
This should kill ALL the processes running that httpd instance and then you get simply start back up your server.
Must stop it first though or it will continue running again.
Mac OSX comes bundled with Apache, however it is deactivated. You might have activated it somehow. In my case, I have previously install XAMPP and configured something in the /etc/apache2/httpd.conf that leads my port localhost:80 to leads to html page with It Works!.
TLDR, the solution is to deactivate the Apache2 server.
Go to your terminal, and type this
sudo apachetl -k stop
In my case, it returns the following:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Shafies-MacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message
httpd (no pid file) not running
if you typed localhost on your browser, the port 80 is not active anymore and you will not see It Works! anymore.
For context, I have deleted XAMPP long time ago and not aware that my localhost:80 is still active. I am not able redirect dummy domain -- posts.com to my localhost port for my kubernetes YAML config files.
This is my ingress-srv.yaml file:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-srv
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
rules:
- host: posts.com
http:
paths:
- path: /?(.*)
backend:
serviceName: client-srv
servicePort: 3000
and I have tricked the operating system to redirect my posts.com to localhost:80 by adding below line in the hosts file located at /etc/hosts
127.0.0.1 posts.com
by SM

Can't access docker container on port 80 on OSX

In my current job we have development environment made with docker-compose.
One container is nginx, which provide routing to other containers.
Everything seems fine and work to my colleague on windows and osx. But on my system (osx El Capitan), there is problem with accessing nginx container on port 80.
There is setup of container from docker-compose.yml
nginx:
build: ./dockerbuild/nginx
ports:
- 80:80
links:
- php
volumes_from:
- app
... and more
In ./dockerbuild/nginx there is nothing special, just nginx config as we know it from everywhere.
When I run everyting with docker-compose create and docker-compose start. Then docker ps give me
3b296c1e4775 docker_nginx "nginx -g 'daemon off" About an hour ago Up 47 minutes 0.0.0.0:80->80/tcp, 443/tcp docker_nginx_1
But when I try to access it for example via curl I get error. curl: (7) Failed to connect to localhost port 80: Connection refused
I try to run container with port 81 and everything works fine.
Port is really binded to docker
22:47 $ sudo lsof -i -n -P | grep TCP
...
com.docke 14718 schovi 38u IPv4 0x6e9c93c51ec4b617 0t0 TCP *:80 (LISTEN)
...
Firewall in osx is turned off and I have no other security.
if you are using docker-for-mac:
Accessing by localhost:80 is correct, though you still have to ensure you do not have a local apache/nginx service running. Often leftovers from boxen/homebrew exist binding that port, because thats what developers did back then :)
if you are using dockertoolbox/virtualbox/whatever hypervisor
You will not be able to access it by localhost, by by the docker-machine ip, so write docker-machine ip default and the use http://$ip:80 in your browser
if that does not help
Ensure your nginx container actually does work, so connect to the container: docker exec -i -t <containerid> bash
and then run ps aux nginx or if telnet is installed try to connect to localhost
Solved!
Problem was, that long long time ago I installed pow (super simple automated rails server which run application on app_name.local domain). And this beast left LaunchAgent script which update pf to forward port 80 to pow port.
In my current job we have development environment made with docker-compose.
A privilege to use.
[W]hen I try to access [nginx on port 80] for example via curl I get error.
Given there's nothing from causing you from accessing docker on your host os you should look at the app running inside the container to ensure it's binding to the correct host, e.g. 0.0.0.0 and not localhost.
For example, if you're running Nuxt inside a container with nuxt-ts observe Nuxt will default to localhost thereby causing the container not to connect to the docker network whereas npx nuxt-ts -H 0.0.0.0 gets things squared away with the container's internal server connecting to the ip of the docker network used (verify ip like docker container inspect d8af01990363).

The port 80 in Mac is used

We have to use port 80 for our server. But when I was trying to use it in Mac, it always said that the 80 is used, but I don't know which program uses it.
I searched it in Google, and someone said it's about apache, but I tried, which is not working. I found this: https://gist.github.com/kujohn/7209628 , but seems it's not working visiting our server by IP address.
I really don't know what's going on and how can I find out which program using port 80 and stop it.
Many thanks if anyone can help, I'm new using Mac. Thanks.
To find out what process is using port 80
go to Applications
open utilities.
open Activity Monitor.
click on the Memory tab,
look at the ports and the processes using them. Find port 80 and select it
go to the view on the menu bar and choose Quit process.
This will just kill the process, it will not stop a server instance that is already running from continuing to run.
(Correction: the Ports column shows the number of open ports (and files?), not the port number)
It is not clear if you are using a database management system or not and which one but one method that has worked for me using MAMP is as follows.
stop the server by using sudo apachectl stop command.
then change the port to port 80.
then restart your servers.
type the following in Terminal
sudo lsof -i -n -P | grep TCP
you will get a list - e.g. dropbox listens on 80
you can copy the output to a text editor, etc to search
On Mac ports below 1024 can only be bound by the root user.
Try launching your server as root user (with sudo), or try to use a port above 1024.
You can also try to add root permissions to your user in /etc/sudoers
# root and users in group wheel can run anything on any machine as any user
root ALL = (ALL) ALL
%admin ALL = (ALL) ALL
your_user_here ALL = (ALL) ALL
I was having this issue, apache was disabled via launchctl, but was still tying up port 80 after launch, I could start up apache and it would work, but after unloading it, I couldn't start up anything on port 80. I was using the built in web server for Python as an easy test. It would work on port 81, but not on port 80.
sudo python -m SimpleHTTPServer 80 -- wouldn't work
sudo python -m SimpleHTTPServer 81 -- would work
Here are the symptoms:
$ launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
$ sudo lsof -i ':80'
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Python 3353 root 3u IPv4 0xe455777a82799f05 0t0 TCP *:http (LISTEN)
The fix for me (after way too much searching) was simple:
sudo pfctl -F all
This flushed the packet filter, releasing port 80 (and others I assume 8080, 443, whatever ports apache might be tying up)
After that, and relaunching the python server, it came right up.
Might be Skype that is using port 80. If you have Skype installed and running try to change to a different port in the settings.
Port numbers in the range from 0 to 1023 are classified as 'well-known' and port number 80 is reserved for HTTP. Typically you have servers listening on port 80 to handle HTTP requests.
Source:
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Phusion passenger can't free port

Ok, i'm running passenger standalone, and made a dumb mistake, now I need help fixing.
So a test app directory was running standalone passenger on a specific port, and I deleted the directory so that I could pull a new app in place of it (and use the same port). Well, not thinking about passenger at all, I should have stopped the daemon first. Well, now the port is tied up somewhere, and I cannot figure out for the life of me how to stop it. I found the process that the port started on, and killed it, but to no avail. The address is still bound and unusable.
Short of restarting the server (not really a viable solution for me), how can I kill that nginx / passenger process all together so that I can start a new instance of passenger on that port?
Run lsof -i :portnumber e.g. lsof -i :3000
You will get something like this ...
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Passenger 10514 USERNAME 5u IPv4 0xea95336b89bfa931 0t0 TCP *:hbci (LISTEN)
Passenger 10515 USERNAME 5u IPv4 0xea95336b89bfa931 0t0 TCP *:hbci (LISTEN)
Stop the processes using kill PID ... something like kill 10514
Passenger Standalone starts Nginx for you, and that is what is actually bound to the port. Because you deleted the directory, Passenger Standalone cannot access Nginx's lock file or PID file, and that's why upon killing Passenger Standalone it could cannot kill Nginx for you. You should kill Nginx manually.

Resources