How to create a Mirroring Endpoint on Principal, Mirror and Witness SQL Server

Create a Mirroring Endpoint on Principle and Mirror Instance with ROLE=PARTNER:

On Principal Server run:

CREATE ENDPOINT Endpoint_Mirroring
STATE=STARTED
AS TCP (LISTENER_PORT=5022)
FOR DATABASE_MIRRORING (ROLE=PARTNER)
GO

On Mirror Server run:

CREATE ENDPOINT Endpoint_Mirroring
STATE=STARTED
AS TCP (LISTENER_PORT=5023)
FOR DATABASE_MIRRORING (ROLE=PARTNER)
GO

Create a Mirroring Endpoint on Witness Instance with ROLE=WITNESS:

On Witness Server run:

CREATE ENDPOINT Endpoint_Mirroring
STATE=STARTED
AS TCP (LISTENER_PORT=5024)
FOR DATABASE_MIRRORING (ROLE=WITNESS)
GO

After creating the endpoints, check their state by querying the sys.database_mirroring_endpoints system catalog view on each server:

SELECT name, state_desc, role_desc
FROM sys.database_mirroring_endpoints

mirroring endpoint state in sql server