Close port 8080 on Mavericks - port

I'm attempting to run Vagrantpress, which be default forwards the VM port 80 to the host port 8080. However, it reports that another application is using port 8080 and fails to boot.
Looking around, it seems that using something like lsof | grep :8080 should list the application using the port. However, that command returns empty.
Using Mavericks' Network Utility > Port Scan I get this:
Port Scan has started…
Port Scanning host: 127.0.0.1
Open TCP Port: 80 http
Open TCP Port: 631 ipp
Open TCP Port: 1023
Open TCP Port: 3128 ndl-aas
Open TCP Port: 5001 commplex-link
Open TCP Port: 5003 fmpro-internal
Open TCP Port: 5432 postgresql
Open TCP Port: 8080 http-alt
Open TCP Port: 20559
Open TCP Port: 29754
Open TCP Port: 49524
Open TCP Port: 49525
Port Scan has completed…
But I can't figure out how to close http-alt so that the port can be used by another application.

I have the same problem and I have Cisco AnyConnect installed, which the answer on https://apple.stackexchange.com/questions/66158/unkown-process-listening-at-port-8080 indicates could be the problem. I decided to change the port I was using instead of trying to get rid of the AnyConnect requirement so I can't verify that as a solution, but it's something to try.

You should run lsof -i :8080 instead of lsof | grep :8080, or netstat -nap | grep :8080 (You may need to change the options on OS X as it is BSD), get the PID of the process and terminate / kill it.
If you just want to work around the issue, use auto_correct: true in the port forward block, for example
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 8080,
auto_correct: true
end
and do a vagrant reload.

Related

When to perform host-ip based port mapping like "-p host-ip:port:port"

Docker provides a way to map ports between the container and host.
As per the official documentation its also possible to mention host-ip while port mapping.
-p 192.168.1.100:8080:80 - Map TCP port 80 in the container to port 8080 on the Docker host for connections to host IP 192.168.1.100.
I tried this option to figure out what's the difference with/without the host-ip.
Using just -p 80:80
$ docker run -itd -p 80:80 nginx:alpine
$ curl localhost:80
$ curl 127.0.0.1:80
$ curl 0.0.0.0:80
$ curl 192.168.0.13:80
$ ps -ef | grep docker-proxy
16723 root 0:00 /usr/local/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.17.0.1 -container-port 80
$
All the curl commands return the output.
Using host-ip like -p 192.168.0.13:80:80
$ docker run -itd -p 192.168.0.13:80:80 nginx:alpine
$ curl localhost:80
curl: (7) Failed to connect to localhost port 80: Connection refused
$ curl 127.0.0.1:80
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
$ curl 0.0.0.0:80
curl: (7) Failed to connect to 0.0.0.0 port 80: Connection refused
$ curl 192.168.0.13:80 # return output
$ ps -ef | grep docker-proxy
4914 root 0:00 /usr/local/bin/docker-proxy -proto tcp -host-ip 192.168.0.13 -host-port 80 -container-ip 172.17.0.2 -container-port 80
$
All the curl commands failed except 192.168.0.13:80.
Is there any there any other difference apart for the one I mentioned here.
Wondering when to use host-ip based port mapping. Any use cases?
A docker host may have multiple NICs. In the data center, this may be too segregate traffic, e.g. management, storage, and application/public. On your laptop, this may be for wireless and wired interfaces. There are also virtual NICs for things like loopback (127.0.0.1) and VPN tunnels.
When you do not specify an IP in the port publish command, by default docker will bind to all interfaces on the host. In IPv4, this is commonly notated as 0.0.0.0 which means listen on any interface (and this is why I don't connect to this address because there's no such thing as connecting to any IP). With the IP address specified, you manually specify which interface to use. Why would you want to specify this? Several reasons I can think of:
Listening on only 127.0.0.1 to prevent external access
Listening on 0.0.0.0 to explicitly bind to all IPv4 interfaces (it is possible to change docker's default behavior, so this could be necessary for some).
Listening on one physical NIC, allowing other NICs to be bound by other services on the same port.
Listening on only IPv4 interfaces if the app does not work for IPv6.
While there are lots of possible reasons, other than listening on loopback for security, these use cases are very rare and most users leave docker to listen on all interfaces.

How to open TCP and UDP ports on Mac

How can I open specific ports in order to use a SDK for a project?
I have already tried netcat, but it seems that you can only listen to a specific port or open a specific port if you have a hosting website.
To open a port and keep listening on it, on macOS this should be working:
nc -lk 8080
To test you can connect to the opened port by doing:
nc -vt 0 8080
To use UDP, you just need to use option -u, for example:
nc -u -lk 8080
To test you can connect:
nc -u -vt 0 8080
Output:
found 0 associations
found 1 connections:
1: flags=82<CONNECTED,PREFERRED>
outif (null)
src 127.0.0.1 port 63214
dst 127.0.0.1 port 8080
rank info not available
Connection to 0 port 8080 [udp/http-alt] succeeded!

how to forward docker port 2375 from virtualbox to host os windows 10

I created a debian vm to have my docker host running on.
netstat
tcp 0 0 127.0.0.1:2375 0.0.0.0:* LISTEN 1260/dockerd
After that I setup port forwarding for port 2375 as described in many online tutorials.
Next I curl in the cmd of my windows 10 host os.
C:\Users\me>curl localhost:2375
curl: (56) Recv failure: Connection was reset
Notice that connecting to the VMs SSH port is working.
C:\Users\me>curl localhost:666
SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u1
Protocol mismatch.
Can anybody tell me what am I missing? Do I have to kinda allow port 2375 to be called from outside where the SSH port is allowed by default?
The issue is with your docker listening IP.
tcp 0 0 127.0.0.1:2375 0.0.0.0:* LISTEN 1260/dockerd
127.0.0.1 means it is only listening for connections generated from inside the VM.
You should change your docker daemon to use 0.0.0.0:2375. Then your port forwarding would work

Having trouble running postgresql with vagrant

So I'm working on a ruby on rails project with a team, and they use ubuntu through vagrant to host the database (in postgresql), so all the rails commands are still executed from the host machine (windows).
Basically, I'm having troubles connecting the two ends, everytime I try to go on any page, it tells me
PG::ConnectionBad
could not connect to server: Cannot assign requested address (0x00002741/10049) Is the server running on host "0.0.0.0" and accepting TCP/IP connections on port 6543?
The Vagrantfile forwards the port 6543 to 5432
config.vm.network :forwarded_port, guest: 5432, host: 6543
and when I ssh into vagrant, it does indeed seem to be listening on that port:
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
I don't know what's not working, I've even tried disabling the firewall to check whether that was the issue, but it wasn't.
I welcome any help that can be offered.
Thank you
EDIT: After reading this, I looked at my pg_hba.conf file, but it looks like it's allowing all connections:
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::/0 trust

Unix domain or TCP

I have a fairly simple Rails app that connect to Postgres server (locally).
Uptil now, I was under the impression if not specified (socket in the database.yml) the pg client connect with postgres over TCP on a loopback interface.
Fyi,this is how my configuration looks like.
{:adapter=>"postgresql", :encoding=>"unicode", :database=>"scp_development"}
But I think I was wrong I can't sniff any packet over the loopback interface at port 5432.
sudo tcpdump -nnvvXSs 1514 -i lo0 dst port 5432
Which is letting me believe that it working over Unix domain socket.
So, is there a fairly reliable way to determine ...
Whether I'm connected to TCP socket or Unix socket?

Resources