Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Increase ssh connection timeout

I keep getting the error "Connection to closed by remote host." because my git hooks take long to complete, is there a way to increase the connection timeout?

1 answer

0 votes

Hi Paulo,

Could you please let us know
1. What operation gives you that error? Is it clone, pull or push?
2. What kind of hooks are you using, is it a client-side pre-push hook or something else?
3. How long approximately after you start the operation do you see it timing out?
4. What OS and SSH client are you using? I'm asking because SSH configuration is set differently depending on that.

Kind regards,

Here are the answers:

1 - It's a push.
2 - Yes, a client side pre-push hook.
3 - Around 3-4 minutes.
4 - Mac OS.

Hi Paulo,

Thanks for the info. I would suggest first checking the files /etc/ssh/ssh_config file (system-wide ssh configuration) and ~/.ssh/config (ssh configuration for your user) in your laptop, and see if there are any values set for ServerAliveInterval and ServerAliveCountMax (either for Host * or for Host

If you don't see these options in any of the two files, what you can do to keep the connection open for longer would be to add the following in either of the files:

ServerAliveInterval 300
ServerAliveCountMax 2

The above values are just an example and you can adjust them depending on how long your hook needs to finish. What these settings will do is make your SSH client send a null packet to Bitbucket every 300 seconds (5 minutes) and give up if it doesn't receive a response after 2 tries. This will give you 10 minutes before the connection times out, if the hook takes longer to complete you can set a higher value to either or both of the options.

Please feel free to let me know how it goes and if you need anything further.

Kind regards,

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,243 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you