# Stop hugo to use 1313 port

**URL:** <https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241>\
**Category:** Uncategorized\
**Created:** [March 25, 2020, 9:30am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241 "2020-03-25T09:30:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![amene\_deljoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/amene_deljoo/32/10497_2.png) [@amene\_deljoo](https://discourse.gohugo.io/u/amene_deljoo)\
**Post date:** [March 25, 2020, 9:30am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/1 "2020-03-25T09:30:31Z")

</div>

I run my docker hugo with : CMD hugo server -b ${HUGO\_BASE\_URL} --bind=0.0.0.0,  
the result is [https://myurl:1313](https://myurl:1313). I need to have the url without any port as the result. How can I run hugo for this matter?  
I set the port on my server-side and need to disable it. hugo version: 0.68.2 , extended version.

---

<div class="post-metadata">

**Author:** ![klakegg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/klakegg/32/6373_2.png) [@klakegg](https://discourse.gohugo.io/u/klakegg)\
**Post date:** [March 25, 2020, 9:45am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/2 "2020-03-25T09:45:26Z")

</div>

Hi,

Using argument “-p”/"–port" will make it possible to change the port used.

I fully trust @bep and the Hugo product, however I’d never use the built-in Hugo server to serve my website in production, and especially not visible to the whole world. If you are looking for an out-of-the-box solution, please see how Hugo may be combined to build an image where nginx is used to serve your webpage:

> **[klakegg/docker-hugo](https://github.com/klakegg/docker-hugo#using-an-onbuild-image)**
>
> Truly minimal Docker images for Hugo open-source static site generator. - klakegg/docker-hugo

---

<div class="post-metadata">

**Author:** ![amene\_deljoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/amene_deljoo/32/10497_2.png) [@amene\_deljoo](https://discourse.gohugo.io/u/amene_deljoo)\
**Post date:** [March 25, 2020, 9:53am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/3 "2020-03-25T09:53:20Z")

</div>

I want the url without any port number after that. I know about -p but it does not answer my question. It is visible to the outside world. However, the production server has own specific requirements. Right now, I am using the docker image by [https://github.com/publysher/docker-hugo/blob/master/Dockerfile](https://github.com/publysher/docker-hugo/blob/master/Dockerfile)  
and I see there is Nginx on the build line.

---

<div class="post-metadata">

**Author:** ![klakegg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/klakegg/32/6373_2.png) [@klakegg](https://discourse.gohugo.io/u/klakegg)\
**Post date:** [March 25, 2020, 9:58am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/4 "2020-03-25T09:58:31Z")

</div>

The default port for “http” is 80, thus setting port to port 80 will result in no need to specify port for “http”.

The Docker image you point to does not result in an image using nginx, I’d still propose the solution I linked to. (Bonus: the image you end up with uses port 80.)

---

<div class="post-metadata">

**Author:** ![amene\_deljoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/amene_deljoo/32/10497_2.png) [@amene\_deljoo](https://discourse.gohugo.io/u/amene_deljoo)\
**Post date:** [March 25, 2020, 10:00am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/5 "2020-03-25T10:00:46Z")

</div>

So, if I use -p 80:80 then the url will be serve without anu port attached to it? Sorry, it might be silly, but can you point me to an image that uses the nginx to serve website.

---

<div class="post-metadata">

**Author:** ![klakegg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/klakegg/32/6373_2.png) [@klakegg](https://discourse.gohugo.io/u/klakegg)\
**Post date:** [March 25, 2020, 10:07am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/6 "2020-03-25T10:07:46Z")

</div>

When you override port when running “hugo server [-p]” to change the port used by hugo, you must also change the docker command accordingly. If you do not override port used by hugo and want to change only the docker port binding, then may “-p 80:1313” be used. Information regarding use of docker on this matter is available here:

> **[docker run](https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose)**
>
> Description Run a command in a new container Usage docker run \[OPTIONS\] IMAGE \[COMMAND\] \[ARG...\] Extended description The docker run command first creates a writeable container layer over the specified...

The link in my first answer should make to jump directly to the “Using an ONBUILD image” section containing a concrete example for Dockerfile resulting in an image using nginx for publishing.

---

<div class="post-metadata">

**Author:** ![amene\_deljoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/amene_deljoo/32/10497_2.png) [@amene\_deljoo](https://discourse.gohugo.io/u/amene_deljoo)\
**Post date:** [March 25, 2020, 10:13am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/7 "2020-03-25T10:13:50Z")

</div>

You mean this part  
FROM klakegg/hugo:0.68.3-onbuild AS hugo

FROM nginx  
COPY --from=hugo /target /usr/share/nginx/html

---

<div class="post-metadata">

**Author:** ![klakegg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/klakegg/32/6373_2.png) [@klakegg](https://discourse.gohugo.io/u/klakegg)\
**Post date:** [March 25, 2020, 10:15am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/8 "2020-03-25T10:15:08Z")

</div>

Yes, that is a copy of the example provided.

---

<div class="post-metadata">

**Author:** ![amene\_deljoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/amene_deljoo/32/10497_2.png) [@amene\_deljoo](https://discourse.gohugo.io/u/amene_deljoo)\
**Post date:** [March 25, 2020, 10:28am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/9 "2020-03-25T10:28:55Z")

</div>

Thanks, but still I got the same result after running the docker:  
docker run -p 80:1313 -it (imagename)  
[https://myurl:1313/](https://myurl:1313/)

---

<div class="post-metadata">

**Author:** ![amene\_deljoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/amene_deljoo/32/10497_2.png) [@amene\_deljoo](https://discourse.gohugo.io/u/amene_deljoo)\
**Post date:** [March 25, 2020, 11:49am UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/10 "2020-03-25T11:49:57Z")

</div>

@bep any solution for this problem. I use CMD hugo server --port=80 -b ${HUGO\_BASE\_URL}, then webservers everytime gives me a new port.

---

<div class="post-metadata">

**Author:** ![klakegg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/klakegg/32/6373_2.png) [@klakegg](https://discourse.gohugo.io/u/klakegg)\
**Post date:** [March 25, 2020, 12:53pm UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/12 "2020-03-25T12:53:40Z")

</div>

Does the log contain the following message?

> port 80 already in use, attempting to use an available port

---

<div class="post-metadata">

**Author:** ![amene\_deljoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/amene_deljoo/32/10497_2.png) [@amene\_deljoo](https://discourse.gohugo.io/u/amene_deljoo)\
**Post date:** [March 25, 2020, 12:58pm UTC](https://discourse.gohugo.io/t/stop-hugo-to-use-1313-port/24241/13 "2020-03-25T12:58:25Z")

</div>

no not really. I made it free.  
CMD hugo server --port=80 -b ${HUGO\_BASE\_URL}  
then what I got [https://myurl:3456](https://myurl:3456) and next time another number 🙂
