Port already in use

Hi I have a new installation of Hugo using snap install and when I try to do Hugo server, it gives me an error saying
port 1313 already in use, attempting to use an available port
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x12f0db7]

While I tried looking into similar posts in the same forum, those solutions did not help.

The difficulty here is that it does not go and take a new available port … instead, it gives this huge error.

goroutine 1 [running]:
github.com/gohugoio/hugo/commands.(*serverCmd).server.func1.1()
/build/hugo/parts/hugo/build/commands/server.go:193 +0x437
sync.(*Once).doSlow(0xc0004df1f0, 0xc0006c7758)
/snap/go/4409/src/sync/once.go:66 +0xe3
sync.(*Once).Do(…)
/snap/go/4409/src/sync/once.go:57
github.com/gohugoio/hugo/commands.(*serverCmd).server.func1(0xc0000be410, 0x16a18e6, 0x13)
/build/hugo/parts/hugo/build/commands/server.go:166 +0x8b4
github.com/gohugoio/hugo/commands.(*commandeer).loadConfig(0xc0000be410, 0xc0000b0101, 0x1998700, 0xc00037d060)
/build/hugo/parts/hugo/build/commands/commandeer.go:333 +0x915
github.com/gohugoio/hugo/commands.newCommandeer(0x101, 0xc000315e10, 0x1996560, 0xc000052680, 0xc0004697a0, 0x0, 0x0, 0x0, 0x1545220, 0xc000570900, …)
/build/hugo/parts/hugo/build/commands/commandeer.go:178 +0x20f
github.com/gohugoio/hugo/commands.initializeConfig(0x101, 0xc000315e10, 0x1996560, 0xc000052680, 0xc0004697a0, 0x0, 0x0, 0xc0000c5408)
/build/hugo/parts/hugo/build/commands/hugo.go:123 +0x76
github.com/gohugoio/hugo/commands.(*serverCmd).server(0xc000052680, 0xc000116780, 0xc000510d70, 0x0, 0x5, 0x0, 0x0)
/build/hugo/parts/hugo/build/commands/server.go:238 +0x1c5
github.com/spf13/cobra.(*Command).execute(0xc000116780, 0xc000510d20, 0x5, 0x5, 0xc000116780, 0xc000510d20)
/build/hugo/parts/hugo/go/pkg/mod/github.com/spf13/cobra@v0.0.4-0.20190321000552-67fc4837d267/command.go:762 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0xc000563180, 0xc00037c670, 0xc0006c7ec0, 0x12cc2e2)
/build/hugo/parts/hugo/go/pkg/mod/github.com/spf13/cobra@v0.0.4-0.20190321000552-67fc4837d267/command.go:850 +0x2fb
github.com/gohugoio/hugo/commands.Execute(0xc000032080, 0x6, 0x6, 0x4074ff, 0xc0000400b8, 0x0, 0x0)
/build/hugo/parts/hugo/build/commands/hugo.go:89 +0xb9
main.main()
/build/hugo/parts/hugo/build/main.go:23 +0x6c

Can you help?

It used to work nicely when I had Hugo 55. Now that I have updated to Hugo 58, I am getting this error.

hi,

this happens if you start hugo server twice.

I can’t help with @prabhakar_shanmugam’s question, but want to let you all know that I have no problem running hugo server twice on Windows using hugo v0.58.3. I just tested it and here’s an excerpt from the second instance of hugo server:

port 1313 already in use, attempting to use an available port
Building sites …
 : 
 :  
Web Server is available at //localhost:63987/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Good luck debugging this!

Hi

Thanks for the reply.

I restarted the system to be sure if thats not the case.

In a fresh restart and a fresh terminal i tried and I still get the same.

How to ascertain this and how to delete / kill the other hugo instance.

On a second thought, could it be because I installed Hugo using snapcraft.

Thanks again

Hi

I uninstalled hugo that i installed through snap
I reinstalled using the deb file download from github
It workssss!!!

I thank you again for your time.

May be its the snap install that made it corrupt. I am not sure.

2 Likes