With emacs 25.2.2 on Ubuntu 18.04, if I try opening a file over ssh using a path such as /ssh:somehost.example.com:/tmp/testfile, it launches a sub-process that does:

/usr/bin/ssh -o ControlPath=%C

This IP address does not accept ssh connections, so the ssh subprocess hangs, and the file opening in emacs also hangs until the ssh eventually times out. Using lsof, it can be seen that the TCP connection to is stuck in SYN_SENT state, consistent with it not receiving any response.

I found that it is possible to work around this by adding an iptables rule to reject the outgoing ssh connection to this address:

sudo iptables -A OUTPUT -d -p tcp --dport 22 -j REJECT

so that this attempted ssh connection quickly receives a "connection refused", instead of the packet effectively being dropped and it just hanging. After this, emacs then connects to the actual target machine correctly, and the remote file can be edited.

Why is this connection to being attempted, and how can this be prevented (in a way that does not require sudo access)?

1 Answer 1


The command /usr/bin/ssh -o ControlPath=%C is used to check, whether your local ssh command accepts the ControlPath option. is a non-existing address; ssh shall return immediately with an error.

In more recent Tramp versions, the blocking is avoided by using the command ssh -o ConnectTimeout=1 -o ControlPath=%C I recommend to upgrade to the Tramp version provided by GNU ELPA.

  • Thank you - I will investigate upgrading.
    – alani
    Commented Sep 6, 2020 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.