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

    <schemaVersion>X0508</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2025-01-31</periodOfReport>

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

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001608411</rptOwnerCik>
            <rptOwnerName>Bracey William G.</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>

    <aff10b5One>0</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2025-01-31</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>A</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
                <footnoteId id="F1"/>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>140</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>0</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>A</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>5113.7960</value>
                    <footnoteId id="F2"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>22292</value>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>By Bracey's Supermarket, Inc.</value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">Mr. Bracey was granted a stock award pursuant to Peoples Financial Services Corp.'s director compensation plan.</footnote>
        <footnote id="F2">This amount includes 26.875 shares acquire in September 2024 and 22.461 shares acquired in December 2024 by Mr. Bracey pursuant to the Issuer's Dividend Reinvestment Stock Purchase Plan.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ James M. Bone, Jr., CPA, As Attorney-in-Fact for William G. Bracey</signatureName>
        <signatureDate>2025-02-04</signatureDate>
    </ownerSignature>
</ownershipDocument>
