Hot answers tagged

51 votes

Forward local port or socket file to remote socket file

Altough in the time, when the question was asked, it was really impossible, but it is possible nowadays. You can to both: UNIX=>TCP and UNIX=>UNIX forwarding. For example: ssh \ -R/var/run/mysql....
34 votes

How to automatically restart a service on failure in Linux

Only answering the service restart part. I came across Monit as well, but on CentOS 7 systemd takes care of all that for you. You just need to add these two lines to the .service file (if they're not ...
  • 538
31 votes

What is the difference between Unix sockets and TCP/IP sockets?

What's the difference between Unix socket and TCP/IP socket? A TCP/IP socket is used for communication across TCP/IP networks. A connected TCP socket is identified by the combination of local IP, ...
  • 4,086
18 votes
Accepted

Running a websocket server and a http server on the same server

A terribly written question, but the term I was looking for was reverse proxy. Basically, just like how nginx can forward different request to several instances of the web app based on the path or ...
  • 412
17 votes

How to find other end of unix socket connection?

Actually, ss from iproute2 (replacement for netstat, ifconfig, etc.) can show this information. Here is an example showing an ssh-agent unix domain socket to which a ssh process has connected: $ ...
  • 4,251
17 votes

Can't start mysql service

Run mysqld --help and check, if it reports any problems with config Check logs in /var/log/mysql Try runnig it directly and check errors: mkdir /var/run/mysqld/ chown mysql: /var/run/mysqld/ mysqld ...
17 votes
Accepted

Expose a Unix socket to the host system from inside from a Docker container

You can communicate the host machine or even two containers using the same socket. In the general case of two containers, you should start the two dockers from the host machine sharing a volume that ...
16 votes

Create Unix Named Socket from the Command Line

You can use python: python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/tmp/test.sock')" Also C, see this answer.
  • 1,138
14 votes

Create Unix Named Socket from the Command Line

I simply use netcat and stay listening in such a case: nc -lkU aSocket.sock you should use netcat-openbsd. netcat-traditional does not have -U switch which is for Unix Domain socket.
  • 241
13 votes

linux : netstat listening queue length

Let's look into source code, as it's the best documentation in the world of open source. net/ipv4/tcp_diag.c: if (sk->sk_state == TCP_LISTEN) { r->idiag_rqueue = sk->sk_ack_backlog; ...
  • 406
12 votes

Sharing unix socket via docker volume - permission denied

Its now 2015 and I assume the kernel patch the Michael mentions has now made it's way into the stable kernel. I have a working example of 2 docker containers one with php-fpm and the other with nginx ...
12 votes

Siege: descriptor table full sock.c:119: Too many open files

To solve this problem for myself, I had to adjust the OS "ulimit" setting: ulimit -a -- Check current setting ulimit -n 10000 -- Edit setting value Source: https://bugs.debian.org/cgi-bin/bugreport....
11 votes

MySQL Daemon Lock issue

Note to future travelers: It depends on your specific configuration but this is very likely an issue with apparmor. If you don't want to disable locking take a look at syslog and see if you're getting ...
  • 211
9 votes

How to find other end of unix socket connection?

I wrote a tool which uses MvG's gdb method to reliably get socket peer information, kernel debug symbols not needed. To get the process connected to a given socket, pass it the inode number: # ...
9 votes

Forward local port or socket file to remote socket file

No more socat is needed since ssh 6.7. You can forward unix domain sockets directly like: ssh -nNT -L $(pwd)/docker.sock:/var/run/docker.sock user@someremote More info: https://medium.com/@dperny/...
9 votes
Accepted

Netcat not able to bind a listening socket

For netcat in listen mode you should use -p flag to choose listening port, e.g. nc -vvv -l -p 5349. the second error: nnetfd reuseport failed : Protocol not available is related to SO_REUSEPORT ...
  • 3,249
8 votes
Accepted

Connect to Milter service unix:/var/run/opendkim/opendkim.sock: No such file or directory

You will need to set the socket file in spool dir of postfix, e.g: /var/spool/postfix/var/run/opendkim After changing that, you might see problem about permission, then just change group owner of ...
7 votes

TIME_WAIT consumes file descriptors?

The file descriptor is used by application to read/write from the socket. Thus if the application call close(), the file descriptor is immediately released. On the other hand, if the application call ...
  • 386
7 votes

How to set up memcached to use unix socket?

added to /etc/default/memcached: [ ENABLE_MEMCACHED = yes ] && install -d -o memcache -g www-data -m 0770 /var/run/memcached # or use setfacl and whatever user/group you want true # because ...
  • 71
6 votes

What are the ramifications of setting tcp_tw_recycle/reuse to 1?

I just had this bite me, so perhaps someone might benefit from my pain and suffering. First, an involved link with lots of info: http://vincent.bernat.im/en/blog/2014-tcp-time-wait-state-linux.html ...
  • 61
6 votes
Accepted

Redirect subdomains to services on different ports of same server

You cannot directly use a DNS name to map a specific port, in this case where you have a single IP for multiple DNS names. Your best bet would be to setup Apache or NGinx as a Reverse Proxy to map ...
  • 13k
5 votes

Unix socket vs TCP/IP host:port

Pros of Unix domain sockets. Access can be managed through the Unix user permission system either by setting the permissions on the socket itself or by the server reading the usename of the ...
  • 4,086
5 votes

Sniff UNIX domain socket

I know this is not answering the main question, but I've ended up here, searching for just sniffing communication on a socket. I've decided to post for others like me. Here's how I did it: $> sudo ...
5 votes

Apache load balancer for mod_proxy_wstunnel?

According Apache official documentation : https://httpd.apache.org/docs/2.4/en/mod/mod_proxy_balancer.html mod_proxy_balancer requires the service of mod_proxy and it provides load balancing for all ...
5 votes
Accepted

dnsmasq: failed to create listening socket for port 53: Address already in use

You can do this: netstat -tupln you will get result like this: tcp 0 0 :::80 :::* LISTEN 713/httpd take the pid for the process that listening on th port 53 and kill it with this ...
4 votes

Linux command to wait for a SSH server to be up

Something simple like this does the job, waiting 5 seconds between attempts and discarding STDERR until ssh <host> 2> /dev/null do sleep 5 done
  • 41
4 votes

Linux command to wait for a SSH server to be up

This is a 'ping_ssh' script I'm using. It handles timeout cases, fast success, and won't prompt for passwords or be fooled by the port being open but not responding as with 'nc' based solutions. This ...
  • 191
4 votes

How to determine number of open sockets? VM Resource Issues

To watch live MySQL opened connections through UNIX socket, run (as root): watch -n1 'netstat -np | grep -i mysqld'
  • 190
4 votes

ERROR 2002 MYSQL socket /tmp/mysql.sock

I know this is an older post, but I spent the last hour or so bouncing back and forth between serverfault, StackOverflow, and DataBase administrators trying to figure out how to solve this issue after ...
4 votes
Accepted

Using nginx to proxy multiple instances of sockets.io

I was having the exact problem and I found this simple workaround : Configure your client socket.io from your js/html file to connect from subdirectory (The default socket.io setting will have your ...

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