# Problem using non-standard port when deploying with git

**URL:** <https://www.ruby-forum.com/t/problem-using-non-standard-port-when-deploying-with-git/150534>\
**Category:** Deployment\
**Created:** [October 9, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/problem-using-non-standard-port-when-deploying-with-git/150534 "2008-10-09T16:45:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![justus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@justus](https://www.ruby-forum.com/u/justus)\
**Post date:** [October 9, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/problem-using-non-standard-port-when-deploying-with-git/150534/1 "2008-10-09T16:45:14Z")

</div>

Hello,

What do I need to change in the deploy.rb or elsewhere in order to use a  
non-default port number?

Everything is working fine when I use the standard port 22 on my server.  
I’m able to deploy my code with capistrano and github.

Now I changed my port number to something higher -say - 1234.

I also updated the deploy.rb with this line:

‘ssh\_options[:port] = 1234’

This works if I do a single command such as cap deploy:cleanup

BUT when I try to deploy updated code via GitHub I now get the following  
error:

‘ssh: connect to host [github.com](http://github.com) port 1234: Connection refused’

When I remove the ‘ssh\_options[:port] = 1234’ line from deploy.rb again  
this error doesn’t happen but instead:

‘Capistrano::ConnectionError, connection failed for: xx.xx.x.xx  
(Errno::ECONNREFUSED: Connection refused - connect(2))’

So does anybody know how to solve this?  
What do I need to change in the deploy.rb or elsewhere in order to use a  
non-default port number?

Thanks a lot for any help!

Justus

---

<div class="post-metadata">

**Author:** ![justus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@justus](https://www.ruby-forum.com/u/justus)\
**Post date:** [October 9, 2008, 6:09pm UTC](https://www.ruby-forum.com/t/problem-using-non-standard-port-when-deploying-with-git/150534/2 "2008-10-09T18:09:16Z")

</div>

rubyphunk wrote:

> You could add [github.com](http://github.com) to your ~/.ssh/config file and define a non-  
> default port:
> 
> Host [github.com](http://github.com)  
> Port 1234
> 
> rubyphunk
> 
> On 9 Okt., 16:45, Justus O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Hi, thanks.

But this doesn’t work. It looks like it is trying to connect to github  
at this port ('‘ssh: connect to host [github.com](http://github.com) port 1234: Connection  
refused’) but that’s not what I am trying to do.

All I am trying to specify is that to access my production server port  
1234 needs to be used.

How can I specify this correctly in the deploy.rb?

Thanks again,  
Justus

---

<div class="post-metadata">

**Author:** ![justus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@justus](https://www.ruby-forum.com/u/justus)\
**Post date:** [October 9, 2008, 5:10pm UTC](https://www.ruby-forum.com/t/problem-using-non-standard-port-when-deploying-with-git/150534/3 "2008-10-09T17:10:35Z")

</div>

You could add [github.com](http://github.com) to your ~/.ssh/config file and define a non-  
default port:

Host [github.com](http://github.com)  
Port 1234

rubyphunk

On 9 Okt., 16:45, Justus O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![justus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@justus](https://www.ruby-forum.com/u/justus)\
**Post date:** [October 10, 2008, 7:41pm UTC](https://www.ruby-forum.com/t/problem-using-non-standard-port-when-deploying-with-git/150534/4 "2008-10-10T19:41:21Z")

</div>

On Oct 9, 9:09 am, Justus O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> But this doesn’t work. It looks like it is trying to connect to github  
> at this port ('‘ssh: connect to host [github.com](http://github.com) port 1234: Connection  
> refused’) but that’s not what I am trying to do.
> 
> All I am trying to specify is that to access my production server port  
> 1234 needs to be used.
> 
> How can I specify this correctly in the deploy.rb?

You can try putting an entry in your local .ssh/config file (~/.ssh/  
config) that includes the port, and then connecting. I’m not sure if  
it’ll work, but it’s worth a shot. Just add something like:

host = [yourservername.com](http://yourservername.com)  
port = 1234

Now, anytime you try to ssh to [yourservername.com](http://yourservername.com), it’ll try the  
connection over port 1234 instead of 22.
