Sample Header Ad - 728x90

Port not working using systemd

0 votes
0 answers
84 views
I'm migrating to a Linux Red Hat 9 server and can't get my .NET web application to work on a specific port (8343) when using systemd. I'm specifically using Kestrel. I see the following error when debugging:
dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.CertificatePathWatcher
      Created directory watcher for '/etc/pki/tls'.
dbug: Microsoft.AspNetCore.Server.Kestrel.Core.Internal.CertificatePathWatcher
      Created directory watcher for '/etc/pki/tls/cert.pfx'.
dbug: Microsoft.AspNetCore.Server.Kestrel
      Failed to bind to http://[::]:8343  (IPv6Any). Attempting to bind to http://0.0.0.0:8343  instead.
info: Microsoft.Hosting.Lifetime
      Now listening on: https://0.0.0.0:8343 
It doesn't bind right away when the service starts up and then eventually listens on https://0.0.0.0:8343 . When I try and go to https://someurl.com:8343/ or https://someurl.com:8343/healthcheck its not coming up. Here's my service file and shell script below:
#TestApp.service

[Unit]
Description=TestApp
Documentation=''
After=multi-user.target

[Service]
User=someuser
ExecStart=/bin/sh -c /www/someurl.com/TestApp/app.sh
Restart=on-failure
RestartSec=60s

[Install]
WantedBy=multi-user.target
#app.sh

#!/bin/bash
now=$(date +"%Y%m%d_%H%M%S")
cd /www/someurl.com/TestApp/app
set -o pipefail
Kestrel__Endpoints__Https__Certificate__Path="/etc/pki/tls/cert.pfx" Kestrel__Endpoints__Https__Certificate__Password="**********" Kestrel__Endpoints__Https__Url="https://*:8343 " DOTNET_ENVIRONMENT="Staging" ./TestApp 2>&1 | tee /apps/logs/TestApp/output_&now.log
Any insight or suggestions would be greatly appreciated! Thanks!
Asked by user692646 (1 rep)
Dec 26, 2024, 07:31 PM
Last activity: Dec 26, 2024, 11:57 PM