38 votes
Accepted

How do I get only the PID, without any extra information, of a process running on port 3000?

Another possible solution: lsof -t -i :<port> -s <PROTO>:LISTEN For example: # lsof -i :22 -s TCP:LISTEN COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 1392 root 3u ...
Yurij Goncharuk's user avatar
29 votes
Accepted

What's the point of firewalling outgoing connections?

There can be many reasons why someone might want to have outgoing ports closed. Here are some that I have applied to various servers at various times The machine is in a corporate environment where ...
Chris Davies's user avatar
27 votes
Accepted

Linux 64-bit SSH port numbers?

Is it possible to configure Linux to use 64 bit ports? You cannot change a parameter to use 64bit ports in TCP/UDP. You could create similar protocols, but you would only be able to communicate with ...
Eduardo Trápani's user avatar
20 votes

What's the point of firewalling outgoing connections?

To expand on @roaima's answer: Defense in depth. Imagine that one server is compromised by malware. The malware installs a program that starts trying to send spam. By denying outgoing connections on ...
dr_'s user avatar
  • 29.7k
20 votes
Accepted

Why is my LAN cable opening an UDP port on my computer?

From OP's comment: @A.B Yes I use wg. When I disable wg the unconn socket is gone. Why wg does this? It appears the system is configured to bring a WireGuard (tunnel) interface whenever the main ...
A.B's user avatar
  • 36.6k
16 votes

Linux 64-bit SSH port numbers?

Having a 64b port makes it almost impossible to randomly attack a service, targeting either DoS or a login. Like ssh -p 141592653589793238 my.site.com And how would the client know about ...
Gilles 'SO- stop being evil''s user avatar
10 votes

How do I get only the PID, without any extra information, of a process running on port 3000?

Try this: pid=$(fuser 3000/tcp 2>/dev/null) (requires psmisc package) Please note, that this is reliable only when run by the user root. Others user can only hope to find processes running with ...
A.B's user avatar
  • 36.6k
9 votes
Accepted

Given a service name, get its port number?

There are two standard library calls; getservbyname(3) and getservbyport(3). These allow programs to convert a name (e.g. telnet) to a port (23), or from a port back to a name. The typical ...
Stephen Harris's user avatar
8 votes

How to check which localhost's ports are used on the terminal?

You can use use the ss command. $ ss -natu The n option means don't translate addresses to names. The a options means show all (listening and non-listening) connections. The t option means TCP ...
Andy Dalton's user avatar
8 votes
Accepted

Limit bandwidth on a specific port in CentOS 7?

Traffic can be limited using only Linux's Traffic Control. Just to clarify, shadowsocks creates a tunnel with one side as a SOCKS5 proxy (sslocal, I'm assuming that's what is running on the OP's ...
A.B's user avatar
  • 36.6k
8 votes
Accepted

How to list all ports and service with nftables?

Here's my nftables cheat sheet: Load rules: nft -f /etc/sysconfig/nftables.conf (this will append them to the existing ones, so flushing first might be required) Watch rules: nft list ruleset Reset ...
Artem S. Tashkinov's user avatar
8 votes

What's the point of firewalling outgoing connections?

If your server is compromised by malware, it will usually want to communicate to its Command and Control to get the payload to deploy (ransomware, lateral movements, spam, bitcoin mining, ...). If it ...
WoJ's user avatar
  • 1,545
7 votes

Linux 64-bit SSH port numbers?

As others have mentioned, it is not possible as both TCP and UDP use 16 bits for port designation. So you'd have to have all the hosts on the internet change the TCP protocol to something else, which ...
Matija Nalis's user avatar
  • 3,111
7 votes
Accepted

scp when both hosts are remote and use different ports

Specify the ports in source and target URLs: scp -3 scp://host1:port1//path/to/file scp://host2:port2//path/to/file
scottbiker's user avatar
7 votes

what is BHFHS protocol port 248?

Port 248 is registered by John Kelly from Bell & Howell for bhfs. Normally, you should contact him before using the port he registered. However, the e-mail is no longer valid and it is impossible ...
Ljm Dullaart's user avatar
  • 4,688
5 votes

How do I get only the PID, without any extra information, of a process running on port 3000?

While lsof's -t is the simplest way to get the PID, lsof also has ways to select other fields using the -F option: $ lsof -F'?' lsof: ID field description a access: r = read; w = write; ...
muru's user avatar
  • 72.9k
5 votes
Accepted

Opening port not working

Your netstat output shows you the problem: tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 743/python Specifically, 127.0.0.1:8000 shows that your web server is bound ...
DopeGhoti's user avatar
  • 76.1k
5 votes
Accepted

How to install MySQL on Ubuntu with a particular IP address on a particular port?

This configuration typically happens in my.cnf, which is usually is /etc/my.cnf or /etc/mysql/my.cnf. [mysqld] bind-address = 127.0.0.1 port = 3306 Edit the configuration file specifying ...
arcsin's user avatar
  • 84
5 votes
Accepted

One port is listening with an * and the other is listening with 127.0.0.1 and only the first is accepting remote connections

A port listening on 127.0.0.1 indicates that it is only listening on the loopback network interface (lo), meaning it can only be accessed from localhost. This is usually the default for security ...
user48052's user avatar
  • 174
5 votes
Accepted

Testing connectivity and port availability using SSH instead of Telnet

I guess you can be certain that ssh is installed, but not nc. In light of that, the question could make sense. Use the -p option. For example port open: $ ssh -p 111 192.168.1.16 ...
berndbausch's user avatar
  • 3,557
5 votes
Accepted

What's the impact of setting pasv_min_port=pasv_max_port in vsftpd?

TL; DR: The impact is that your FTP server will only support 1 transfer at a time. Definitely a no-no for FTP servers meant to serve concurrent clients. It might be ok for a private FTP server used by ...
LL3's user avatar
  • 5,428
5 votes
Accepted

netcat closing connection on localhost listening end after connection attempt

There are many different implementations of netcat. I'll assume you are not using the traditional implementation but a more modern one, which can handle IPv6, because 1st issue looks related to IPv6. ...
A.B's user avatar
  • 36.6k
4 votes

Port open/listen but no associated process

As hinted at, ss can provide the answer as well; the syntax is: sudo ss --tcp --listening --processes 'sport = 1234' Where 1234 is the port-of-the-day from your nmap scan. This limits the output to ...
Jeff Schaller's user avatar
  • 67.3k
4 votes
Accepted

systemd opens socket, service fails to bind to this socket

What am I doing wrong? You haven't written any actual test program code. Nearly every single line of code in your test program so far is unnecessary. systemd has opened the socket, bound it, and ...
JdeBP's user avatar
  • 68.8k
4 votes
Accepted

Restrict inbound access on localhost:TCP port

There is an owner match extension in iptables, but it can only be used in OUTPUT and POSTROUTING chains. So you could add two rules in the very beginning of the iptables OUTPUT chain like this (root ...
telcoM's user avatar
  • 96.9k
4 votes

Linux's Internet domain socket, transport protocols (TCP/UDP)'s socket and port

Sockets are an operating system API. This API lets applications on same or different systems communicate over the TCP and UDP (and other) protocols. UNIX domain sockets (not internet domain sockets as ...
Steffen Ullrich's user avatar
4 votes
Accepted

Why does postgresql server have a `localhost:57504` to `localhost:57504` UDP "connection"?

A little bit of digging this is the stats collector. Apparently stats are posted on local loopback (aka localhost) UDP. See here: http://www.neilconway.org/talks/hacking/ottawa/ottawa_slides.pdf . ...
Philip Couling's user avatar
4 votes
Accepted

Does `rpcinfo` list the port number of a RPC service?

This version of rpcinfo seems to be a bit hasty implementation, as the port number is displayed as two individual bytes instead of a single 16-bit number. The portmapper service is always expected to ...
telcoM's user avatar
  • 96.9k
4 votes

Routing port traffic over specific interface

As I told in the comment linked from OP, starting with Linux kernel 4.17, using iptables (or anything netfilter related) is not needed anymore to solve this problem. The newer feature available to ...
A.B's user avatar
  • 36.6k
4 votes

Port 3000 is always being hogged by grafana-server

I have been struggling to figure this out for mac. This page kept showing up. So, to help other mac users please use the following command brew services stop grafana
dev-katiyar's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible