Take the 2-minute tour ×

I have a git repository on my local machine that I push to github and a staging server, which is hosted with HostGator. I followed this guide to setup my staging server to allow me to push to it, which has worked well in the past.

After not pushing anything for about a month, I now see this error when I try to push to the staging server (where [hostname] is replaced with my url):

ssh: connect to host [hostname] port 22: Operation timed out
fatal: The remote end hung up unexpectedly

git remote -v shows:

bright  [user]@[hostname]:[path to repo] (fetch)
bright  [user]@[hostname]:[path to repo] (push)
origin  git@github.com:[reponame.git] (fetch)
origin  git@github.com:[reponame.git] (push)

The relevant portion of my .git/config is as follows:

[remote "[remote in question"]
    url = [user]@[hostname]:[path to repo]
    fetch = +refs/heads/*:refs/remotes/[remote]/*

It may be worth noting that when I ssh into this server, I use port 2222, but as you can see from the error message, git is trying to use port 22. I think that has always been the case though, even when this was working correctly.

What steps can I take to determine why the git push is timing out on my staging server?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Sounds like you may have setup port 2222 in your local ~/.ssh/config file. Maybe that config was replaced or removed?

share|improve this answer
my local ~/.ssh/config specifies port 2222. I'm using a Mac and doing everything via the command line. Looks like I need to figure out how git decides what ssh settings to use. –  tnorthcutt Jan 4 '13 at 17:29
add comment

You need to specify the port in the remote definition use:

url = git://[user]@[host]:2222/[path_to_repo]

This is only possible using the above style url starting with git://.

share|improve this answer
add comment

Your Answer


