i want to run memcache deamons on my local mac osx (latest os( machine for developing. when i start the first instance like:
sudo memcached -m 8mb -l localhost -p 11211 -d -vv
everything seems to be ok. if i make a lsof on the port this is how it looks like:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
memcached 614 root 4u IPv4 0xffffff80113eeda8 0t0 TCP adobe-dns.adobe.com:11211 (LISTEN)
memcached 614 root 5u IPv6 0xffffff800c5c97b0 0t0 TCP localhost:11211 (LISTEN)
memcached 614 root 6u IPv6 0xffffff800c5c94a0 0t0 TCP localhost:11211 (LISTEN)
memcached 614 root 7u IPv4 0xffffff800c3b02c0 0t0 UDP adobe-dns.adobe.com:11211
memcached 614 root 8u IPv6 0xffffff800c3af140 0t0 UDP localhost:11211
memcached 614 root 9u IPv6 0xffffff800c3afa00 0t0 UDP localhost:11211
i find this quite strange ... and if i try the second instance on a new port like:
sudo memcached -m 8mb -l localhost -p 11212 -d -vv
i get an error saying:
failed to listen on UDP port 11211
udp listen: Address already in use
even though im starting the daemon on port 11212. can somebody explain or give any hints what this means - what is happening there
THX
Frank
You need to add -U 0 unless you care about UDP support, in which case you'd want to add -U 11212. We straightened this out a bit more in later versions so it does something more intuitive.
Related
My timing database influx sets the listening port 8088 to address 127.0.0.1, and the spring boot listens to the same port 8088 to any addresses, as shown below.
~ lsof -nP -i:8088
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
influxd 420 zyx 3u IPv4 0xf4af94bc970b15e9 0t0 TCP 127.0.0.1:8088 (LISTEN)
java 34029 zyx 171u IPv6 0xf4af94bc9a0d12e9 0t0 TCP *:8088 (LISTEN)
When I try to access spring boot restful using url localhost:8088/api, I get the right result. But when I use url 127.0.0.1:8088/api, I get error java.net.SocketException: Connection reset.I guess it is caused by mapping to influd instead of spring boot.
But why localhost can get the right result? As far as I konw, localhost will resolve to 127.0.0.1.
I run my program on Mac 2019.
~ nslookup localhost
Server: 192.168.15.1
Address: 192.168.15.1#53
Name: localhost.cluster.peidan.me
Address: 127.0.0.1
I am trying to access a listening tcp socket on my macbook from any external client on the same wi-fi lan.
This works for specific ports, eg. 8000, but not other ports, eg. 8080, 8081, 8082
How can I open up or access the 8080 tcp port externally?
Working steps on port 8000
Server
$ nc -lv 8000
Client
$ nc -z 192.168.101.98 8000
Connection to 192.168.101.98 port 8000 [tcp/irdmi] succeeded!
Non-working steps on port 8080
Server
$ nc -lv 8080
Client
$ nc -z 192.168.101.98 8080
(The command just hangs)
Diagnostics
$ lsof -P -i TCP:8000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 75782 ... 3u IPv4 0x5be3e11e5a732339 0t0 TCP *:8000 (LISTEN)
$ lsof -P -i TCP:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 75952 ... 3u IPv4 0x5be3e11e581e2fb9 0t0 TCP *:8080 (LISTEN)
$ sudo pfctl -s all | grep Status
No ALTQ support in kernel
ALTQ related functions disabled
Status: Disabled Debug: Urgent
I am running macOS Mojave 10.14.1 (same behavior on 10.14 as well).
Update
I changed nothing, everything suddenly works. I am very curious what made the difference. Will close the question, if everything keeps working.
Solution
I had the Endpoint Security VPN client installed. This activates a firewall at all times blocking some ports. Even when not connecting to a vpn server.
By shutting down the client daemon, i can access all ports again.
Steps to shutdown daemon
From: https://gist.github.com/phoob/671e65332c86682d5674
kill client and run commands to stop daemon:
sudo launchctl unload /Library/LaunchDaemons/com.checkpoint.epc.service.plist
sudo kextunload /Library/Extensions/cpfw.kext
OSX 10.11
I installed the latest nginx 1.9.9 (from source and compiled )
the configuration file /usr/local/conf/nginx.conf syntax is ok
when listening on port 8080 no problem I can request http://example.local:8080
server {
listen 8080;
server_name example.local;
root HTML;
And then run:
sudo lsof -i -P | grep -i "80"
nginx 8254 root 10u IPv4 0x643a3abbad7bf485 0t0 TCP *:8080 (LISTEN)
nginx 8392 yves 10u IPv4 0x643a3abbad7bf485 0t0 TCP *:8080 (LISTEN)
BUT when I change the port to 80, I cannot reach http://example.local:80
server {
listen 80;
server_name example.local;
root html;
sudo nginx -s reload
nginx 8254 root 10u IPv4 0x643a3abbad7bf485 0t0 TCP *:8080 (LISTEN)
nginx 8254 root 18u IPv4 0x643a3abbadbb9485 0t0 TCP *:80 (LISTEN)
nginx 8430 yves 10u IPv4 0x643a3abbad7bf485 0t0 TCP *:8080 (LISTEN)
nginx 8430 yves 18u IPv4 0x643a3abbadbb9485 0t0 TCP *:80 (LISTEN)
Safari canot open the page
however I can still request http://example.local:8080
very weird .... Nginx IS LISTENING on 80 ... what can I do ?
You just can run services on ports below to 1024 as sudo.
Running on the go:
$ sudo brew services restart nginx
Starting with the system:
$ sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
$ sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Note that you must set up your server to listen to 80 inside your config file and make sure there's no other process running at port 80.
Check firwall or iptables.
Port 80 might be blocked. Try stopping firewall or iptables service.
If it is blocked, then add entry to allow port 80
I am writing a Ruby script that deploys a server on port 8000 in the background, and then in the foreground I issue queries to the server. After I've issued my queries I kill the server, however when I kill the server, it seems to be switching ports.
I am doing it the following way in the ruby script:
To see PID that is running on port 8000:
lsof -i:8000 -t
Result:
RUNNING ON PORT 8000: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 26364 user1 84u IPv6 199069 0t0 TCP *:8000 (LISTEN)
To kill the server I issue the command:
kill 26364
I then see if anything is running on port 8000:
# check if killed
lsof -i:8000 -t
Result:
RUNNING ON PORT 8000: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 25560 user1 58u IPv4 199123 0t0 TCP localhost:45789->localhost:8000 (ESTABLISHED)
java 26364 user1 84u IPv6 199069 0t0 TCP *:8000 (LISTEN)
java 26364 user1 85u IPv6 199124 0t0 TCP localhost:8000->localhost:45789 (ESTABLISHED)
I only want to kill the process that is listening on port 8000,
and keep my ruby script running.
Can someone please tell me what is going on? Why is it switching ports? How can I only kill my server port?
It doesn't look to me like it's switching ports; it's still listening on port 8000. It looks to me like two things are happening:
The java process (PID 26364) is catching or ignoring the kill signal (SIGTERM), and continuing to listen on port 8000.
A ruby process (PID 25560) is making a connection to localhost:8000 (from port 45789, which was probably dynamically allocated). That is, ruby is making a normal connection to the server on port 8000.
Note that the java process owns the port 8000 end of the localhost:8000<->localhost:45789 TCP session, and the ruby process owns the port 45789 end.
Whether the ruby process's connection is somehow a result of the kill signal, or just something it happened to do at about the same time, I couldn't tell you.
I had a running EC2 server with an elastic IP address that was happily running memcached and beanstalkd listening on the external IP at port 11211 and 11300 respectively. I took a AMI of the server to upgrade the size and when the server restarted, neither memcached nor beanstalkd were running. Troubling for memcached as this was init.d to restart but beanstalkd was run as daemon from command line.
However, after several hours, I can't seem to figure out how to get them up and running again.
For memcached the config file reads:
# Default connection port is 11211
-p 11211
# Specify which IP address to listen on. The default is to listen on all IP addresses
-l <EXTERNAL IP ADDRESS>
When I try and run memcached as root from the command line:
memcached -d -m 1024 -u root -l <EXTERNAL IP ADDRESS> -v -p 11211
I get:
bind(): Cannot assign requested address
failed to listen on TCP port 11211: Cannot assign requested address
Yet when I look at netstat, nothing is bound to that port already:
netstat -ant | grep LIST
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
And if I grep the processlist, there is no other memcached running.
Iptables reports the following:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spt:11300 state ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp spt:11211 state ESTABLISHED
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
The EC2 instance is using the same security group as the original server, so the required ports are open.
Finally, maybe a hint is that the ifconfig IP address is different to the elastic IP address. If I try listening on either the inet adds: Bcast: the memcached service runs and binds however I can't seem to access memcached via the elastic IP.
I MUST be doing something stupid and obvious to you. Thanks for your help.
bind to 0.0.0.0 that should be public.