What ports are used by git and stash?

I have my Linux server set to block all ports except those I actively use.  It works, but I'm having trouble with Stash.  I've tried freeing 20-22 outgoing, 80, 1443, 9418 all incoming and outgoing, along with the http port and control port I use for my setup incoming and outgoing.  Those are the only ports I've seen show up using iptraf.

I am able to connect to my server and Stash from my PC.  I can login, it calculates what's needed for the push and begins to perform the push, actually sends all of the content, but then it fails after a long timeout with the message:

 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://xyz@www.abc.org:####/scm/repo/repo.git'

If I go in and unblock all of the ports, then it works properly and completes the push like normal.  I can't figure out what port it's using.

Thank you in advance for your help. smile

Best regards,
Rick C. Hodgin

2 answers

1 vote

Stash by default uses port 7990 for HTTP and port 7999 for SSH.

We don't use 22 or the git protocol port 9418 so there is no need to open up those for Stash (you may want to keep 22 if you are using the default SSH port to log into the machine).


Some useful documentation if you have plans to integrate a reverse proxy:

Git uses HTTP (80), HTTPS (443), or SSH (22) depending on how the remote is configured.

This post refers also to a git:// protocol that typically runs on 9418: http://serverfault.com/questions/189070/what-firewall-ports-need-to-be-open-to-allow-access-to-external-git-repositories


Stash is configurable but by default uses 7990 and 8006: https://confluence.atlassian.com/display/STASH/Changing+the+port+that+Stash+listens+on


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,773 views 1 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you