62

How do I change gitlab's default port 80 to a custom port number?

There are two approaches I've tried:

Set the port in /etc/gitlab/gitlab.rb

external_port "8888"

Then run reconfigure:

gitlab-ctl reconfigure

Set port in /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

production: &base
  #
  # 1. GitLab app settings
  # ==========================

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: gitlab.blitting.com
    port: 8888
    https: false

Then restart gitlab

gitlab-ctl stop
gitlab-ctl start

With both of these, gitlab continues to run on the default 80 port number.

  • Updating gitlab-http.conf nginx configuration worked, is that the correct process? – Jason Sturges Mar 31 '14 at 0:59
75

Chad Carbert answer still applies but just want to add extra for version 7.0.0.

Open "/etc/gitlab/gitlab.rb" in your text editor where currently I have external_url http://127.0.0.1/ or similar to that. I may need to change external_url with dns including port number (eg. 'http://gitlab.com.local:81/') then reconfigure using command "sudo gitlab-ctl reconfigure" Gitlab is now working on port 81.

Step by step:

  1. sudo -e /etc/gitlab/gitlab.rb
  2. Change external_url from yourdomain.com to yourdomain.com:9999
    9999 -> Port you want it to run
  3. sudo gitlab-ctl reconfigure
  • 1
    For me gitlab is now accessible through both 8080 and 8081 (the port I added). Any idea how I can free up 8080? – DaSh Oct 2 '14 at 23:31
  • 2
    Stopping and starting it again solved the issue. – DaSh Oct 2 '14 at 23:45
  • 1
    If this doesn't work, check the logs using gitlab-ctl tail to find if the ports collide. – dusan Oct 28 '14 at 15:19
  • Is there an alternative command for gitlab-ctl reconfigure if I don't have gitlab-ctl? Just restarting should do, right? – icedwater Feb 3 '15 at 6:37
  • 1
    See the "#unicorn['port'] = '8080'" value in the config file. – emeraldjava Oct 29 '15 at 17:44
6

I'm also having this same issue. I don't have my gitlab.rb in the same location as you, but do have it installed via dpkg at the /opt path you mentioned.

If you've installed it via the package, all self-contained in that /opt directory, then you might find changing the port at :

  • /opt/gitlab/embedded/conf/nginx.conf
  • /opt/gitlab/embedded/cookbooks/gitlab/templates/default/nginx-gitlab-http.conf.erb

Issue #6581: .deb package install on Ubuntu 12.04 - Port number in gitlab.yml file is ignored

  • How did this help? I'm still not getting anywhere with this - gitlab is insisting on using port 80 - which it can't because apache is already using it. Any specifics about what you did? Changing ports in those files did nothing. – Hippyjim Aug 19 '14 at 13:43
6

Very Simple way to change defaults port number

gitlab-ctl stop

edit the file in centos or linux:- /var/opt/gitlab/nginx/conf/gitlab-http.conf

change listen *:80; to what you want Ex:- 90

then

Don't run the command- gitlab-ctl reconfigure

If gitlab-ctl reconfigure it configured gitlab by defaults and remove changes.

so only run- gitlab-ctl start

  • 1
    At least won't work for omnibus package – ALex_hha Apr 23 '16 at 13:54
4

My main issue was that new users were not getting the custom port number in the emails that the system sent. Otherwise, manually writing the custom port in the address bar led users to the Gitlab install.

I did this install on Ubuntu 14.04 instead of the Omnibus. So somehow I don't have gitlab-ctl. (It exists in /usr/bin, but the target of the symlink wasn't installed somehow. I'll fix that separately if I really have to.)

Anyway, I used a variant of the second approach, writing the correct port into /home/git/gitlab/config/gitlab.yml:

production: &base
  #
  # 1. GitLab app settings
  # ==========================

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: my.gitlab.host.com
    port: 3722

Since I don't have gitlab-ctl, I used service:

sudo service gitlab restart

That worked for me. New users that I sent the email to received a link which contained the correct URL.

3

With Ubuntu 17.04 and gitlab-ce 9.2.2, on local network

These steps worked for me:

  1. Edit gitlab.rb file.

sudo nano /etc/gitlab/gitlab.rb

  1. Add your optional listen port to end of file.

nginx['listen_port'] = 8181

  1. Stop apache if needed, and reconfigure gitlab

sudo service apache2 stop sudo gitlab-ctl reconfigure

  1. Start apache if you stop that.

sudo service apache2 start

  1. Finished, now gitlab is available on your ip address with selected port.

'http://localhost:8181'

2

In Amazon Linux using the Centos 6 package I had to configure the file:

/opt/gitlab/embedded/cookbooks/gitlab/attributes/default.rb

and then do the

gitlab-ctl reconfigure 

command to finally get the port change.

2

I'm using Gitlab 7.5.3 omnibus 5.2.1 ci on Debian Squeeze. To change the default port for nginx add the _gitlab_port_ to /etc/gitlab/gitlab.rb:

My /etc/gitlab/gitlab.rb:

external_url = 'gitlab.example.org'
gitlab_rails['gitlab_port'] = 12345

After changing the port, you have to call gitlab-ctl reconfigure and gitlab-ctl restart in your command line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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