<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0206</schemaVersion>

    <documentType>3</documentType>

    <periodOfReport>2024-07-01</periodOfReport>

    <noSecuritiesOwned>1</noSecuritiesOwned>

    <issuer>
        <issuerCik>0001056943</issuerCik>
        <issuerName>PEOPLES FINANCIAL SERVICES CORP.</issuerName>
        <issuerTradingSymbol>PFIS</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001291176</rptOwnerCik>
            <rptOwnerName>Coccia Joseph A</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>C/O PEOPLES SECURITY BANK &amp; TRUST CO.</rptOwnerStreet1>
            <rptOwnerStreet2>150 N. WASHINGTON AVE</rptOwnerStreet2>
            <rptOwnerCity>SCRANTON</rptOwnerCity>
            <rptOwnerState>PA</rptOwnerState>
            <rptOwnerZipCode>18503</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isDirector>1</isDirector>
        </reportingOwnerRelationship>
    </reportingOwner>

    <remarks>See Power of Attorney attached hereto as Exhibit 24.1</remarks>

    <ownerSignature>
        <signatureName>/s/ Stephanie A. Westington, as Attorney-in-Fact for Joseph A. Coccia</signatureName>
        <signatureDate>2024-07-01</signatureDate>
    </ownerSignature>
</ownershipDocument>
