i have a rest api golang app.
with go run .
everything works fine, no error.
then, I dockerize it on localhost. everything seems fine, but endpoints that are connecting to mongo are not working and I am getting this error:
<code>2024/07/21 18:17:20 [Recovery] 2024/07/21 - 18:17:20 panic recovered:
GET /profile/668c2d5250fe***********67df HTTP/1.1
Host: localhost
Accept: */*
Accept-Encoding: gzip, deflate, br
Cache-Control: no-cache
Connection: keep-alive
Cookie: mysession=MTcyMDU1MzY4OXxEWDhFQVFM*********UVp6ZEhKcGJtY01CZ0FFZFhObGNnWnpkSEpwYm1jTUdnQVlhbTk2YTI4dWJYSnJkbWxqYTJGQVoyMWhhV3d1WTI5dHz96d6RYC_LAkezfAtkY7g5w4sSDWXad3I3rBQl0P5oCw==
Postman-Token: 7ec50f3d-d8af-4fa0-9f28-94df36e5beb8
User-Agent: PostmanRuntime/7.40.0
server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: hocico-shard-00-01.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, { Addr: hocico-shard-00-02.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, { Addr: hocico-shard-00-00.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, ] }
/Users/red_dragon/Documents/projects/PartakNaVyletBE/profile/profile.go:54 (0x4b19ab)
/Users/red_dragon/Documents/projects/PartakNaVyletBE/main.go:89 (0x4b4ff7)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x3818ff)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:102 (0x3818e4)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x380c73)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:249 (0x380c44)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x37fca7)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:633 (0x37f82c)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:589 (0x37f57f)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/net/http/server.go:2938 (0x22dabb)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/net/http/server.go:2009 (0x22ac37)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/runtime/asm_arm64.s:1197 (0x78cd3)
</code>
<code>2024/07/21 18:17:20 [Recovery] 2024/07/21 - 18:17:20 panic recovered:
GET /profile/668c2d5250fe***********67df HTTP/1.1
Host: localhost
Accept: */*
Accept-Encoding: gzip, deflate, br
Cache-Control: no-cache
Connection: keep-alive
Cookie: mysession=MTcyMDU1MzY4OXxEWDhFQVFM*********UVp6ZEhKcGJtY01CZ0FFZFhObGNnWnpkSEpwYm1jTUdnQVlhbTk2YTI4dWJYSnJkbWxqYTJGQVoyMWhhV3d1WTI5dHz96d6RYC_LAkezfAtkY7g5w4sSDWXad3I3rBQl0P5oCw==
Postman-Token: 7ec50f3d-d8af-4fa0-9f28-94df36e5beb8
User-Agent: PostmanRuntime/7.40.0
server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: hocico-shard-00-01.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, { Addr: hocico-shard-00-02.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, { Addr: hocico-shard-00-00.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, ] }
/Users/red_dragon/Documents/projects/PartakNaVyletBE/profile/profile.go:54 (0x4b19ab)
/Users/red_dragon/Documents/projects/PartakNaVyletBE/main.go:89 (0x4b4ff7)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x3818ff)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:102 (0x3818e4)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x380c73)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:249 (0x380c44)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x37fca7)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:633 (0x37f82c)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:589 (0x37f57f)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/net/http/server.go:2938 (0x22dabb)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/net/http/server.go:2009 (0x22ac37)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/runtime/asm_arm64.s:1197 (0x78cd3)
</code>
2024/07/21 18:17:20 [Recovery] 2024/07/21 - 18:17:20 panic recovered:
GET /profile/668c2d5250fe***********67df HTTP/1.1
Host: localhost
Accept: */*
Accept-Encoding: gzip, deflate, br
Cache-Control: no-cache
Connection: keep-alive
Cookie: mysession=MTcyMDU1MzY4OXxEWDhFQVFM*********UVp6ZEhKcGJtY01CZ0FFZFhObGNnWnpkSEpwYm1jTUdnQVlhbTk2YTI4dWJYSnJkbWxqYTJGQVoyMWhhV3d1WTI5dHz96d6RYC_LAkezfAtkY7g5w4sSDWXad3I3rBQl0P5oCw==
Postman-Token: 7ec50f3d-d8af-4fa0-9f28-94df36e5beb8
User-Agent: PostmanRuntime/7.40.0
server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: hocico-shard-00-01.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, { Addr: hocico-shard-00-02.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, { Addr: hocico-shard-00-00.kmby4.azure.mongodb.net:27017, Type: Unknown, Last error: tls: failed to verify certificate: x509: certificate signed by unknown authority }, ] }
/Users/red_dragon/Documents/projects/PartakNaVyletBE/profile/profile.go:54 (0x4b19ab)
/Users/red_dragon/Documents/projects/PartakNaVyletBE/main.go:89 (0x4b4ff7)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x3818ff)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:102 (0x3818e4)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x380c73)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:249 (0x380c44)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 (0x37fca7)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:633 (0x37f82c)
/Users/red_dragon/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:589 (0x37f57f)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/net/http/server.go:2938 (0x22dabb)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/net/http/server.go:2009 (0x22ac37)
/opt/homebrew/Cellar/go/1.21.3/libexec/src/runtime/asm_arm64.s:1197 (0x78cd3)
could not find meaning full answer.
Please help. Thanks.
I have tried co compile app outside and inside docker, different dockerfiles, port forwarding… different computers, virtual machines… also from digital ocean droplet. go run .
works, dockerized app cant connect to atlas mongo.