ANAVEM
Languagefr
Data center server room showing Hyper-V virtual switch management console on a monitoring workstation
Event ID 5120ErrorMicrosoft-Windows-Hyper-V-VmSwitchWindows

Windows Event ID 5120 – Microsoft-Windows-Hyper-V-VmSwitch: Virtual Switch Port Connection Failed

Event ID 5120 indicates a Hyper-V virtual switch failed to connect a virtual machine's network adapter to a switch port, typically due to resource constraints or configuration issues.

Emanuel DE ALMEIDAEmanuel DE ALMEIDA
18 March 202612 min read 0
Event ID 5120Microsoft-Windows-Hyper-V-VmSwitch 5 methods 12 min
Event Reference

What This Event Means

Event ID 5120 represents a critical networking failure within the Hyper-V virtualization platform. When this event occurs, it signifies that the Virtual Machine Management Service (VMMS) attempted to connect a virtual machine's network adapter to a virtual switch port but encountered an error that prevented successful establishment of the connection.

The Hyper-V virtual switch architecture relies on a complex interaction between the hypervisor, virtual switch extensions, and the underlying physical network infrastructure. Event 5120 typically indicates a breakdown in this communication chain, often manifesting as complete network isolation for the affected virtual machine. The error can occur at various stages of the connection process, including initial VM startup, live migration operations, or dynamic network configuration changes.

This event is particularly significant in production environments where virtual machines require consistent network connectivity for business-critical applications. The failure can result in service outages, application timeouts, and potential data loss if the affected VMs cannot communicate with external resources or other virtual machines within the same virtualized environment.

The event details usually include specific error codes, virtual machine identifiers, and network adapter information that help administrators pinpoint the exact cause of the connection failure. Understanding these details is essential for implementing targeted troubleshooting strategies and preventing future occurrences of this critical networking error.

Applies to

Windows 10Windows 11Windows Server 2019/2022/2025
Analysis

Possible Causes

  • Insufficient system memory or CPU resources preventing virtual switch port allocation
  • Corrupted virtual switch configuration or damaged virtual switch database
  • Network adapter driver conflicts or outdated Hyper-V integration components
  • Physical network adapter hardware failures or cable connectivity issues
  • Virtual switch extension conflicts or third-party networking software interference
  • Windows networking service failures or TCP/IP stack corruption
  • Antivirus software blocking Hyper-V networking components
  • Registry corruption affecting Hyper-V virtual switch settings
  • VLAN configuration mismatches between virtual and physical switches
  • Hyper-V host overcommitment leading to resource exhaustion
Resolution Methods

Troubleshooting Steps

01

Check Event Viewer and Restart Virtual Switch Service

Start by examining the detailed event information and restarting the Hyper-V virtual switch service to resolve temporary connection issues.

  1. Open Event Viewer and navigate to Applications and Services LogsMicrosoftWindowsHyper-V-VmSwitchOperational
  2. Locate Event ID 5120 and note the virtual machine name, network adapter details, and any error codes
  3. Open PowerShell as Administrator and check virtual switch status:
    Get-VMSwitch | Select-Object Name, SwitchType, NetAdapterInterfaceDescription
    Get-VMNetworkAdapter -All | Where-Object {$_.Status -ne 'Ok'}
  4. Restart the Hyper-V Virtual Machine Management service:
    Restart-Service vmms -Force
    Restart-Service nvspwmi -Force
  5. Verify the virtual switch service is running:
    Get-Service vmms, nvspwmi | Select-Object Name, Status
  6. Attempt to start the affected virtual machine and monitor for recurring Event ID 5120
Pro tip: Check the System event log simultaneously for related hardware or driver errors that might correlate with the virtual switch failure.
02

Recreate Virtual Switch Configuration

Remove and recreate the problematic virtual switch to resolve configuration corruption issues.

  1. Document current virtual switch settings:
    Get-VMSwitch | Export-Csv -Path C:\temp\vmswitch-backup.csv -NoTypeInformation
    Get-VMNetworkAdapter -All | Export-Csv -Path C:\temp\vmnetadapter-backup.csv -NoTypeInformation
  2. Stop all virtual machines connected to the problematic switch:
    $SwitchName = "YourSwitchName"
    Get-VM | Where-Object {(Get-VMNetworkAdapter -VM $_).SwitchName -eq $SwitchName} | Stop-VM -Force
  3. Remove the existing virtual switch:
    Remove-VMSwitch -Name $SwitchName -Force
  4. Recreate the virtual switch with the same configuration:
    # For External Switch
    New-VMSwitch -Name $SwitchName -NetAdapterName "Ethernet" -AllowManagementOS $true
    
    # For Internal Switch
    New-VMSwitch -Name $SwitchName -SwitchType Internal
  5. Reconnect virtual machines to the new switch:
    Get-VM | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName $SwitchName
  6. Start the virtual machines and verify network connectivity
Warning: Removing a virtual switch will disconnect all attached VMs. Ensure you have documented all network configurations before proceeding.
03

Update Network Drivers and Hyper-V Components

Update network adapter drivers and Hyper-V integration services to resolve compatibility issues causing virtual switch failures.

  1. Check current driver versions:
    Get-NetAdapter | Select-Object Name, InterfaceDescription, DriverVersion, DriverDate
    Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
  2. Open Device Manager and expand Network adapters
  3. Right-click the physical network adapter and select Update driver
  4. Download the latest drivers from the manufacturer's website or use Windows Update
  5. Update Hyper-V integration services on all virtual machines:
    Get-VM | Where-Object {$_.State -eq 'Running'} | ForEach-Object {
        Update-VMIntegrationService -VM $_ -Name "Guest Service Interface"
    }
  6. Check for Windows updates that include Hyper-V improvements:
    Get-WindowsUpdate -MicrosoftUpdate | Where-Object {$_.Title -like "*Hyper-V*"}
  7. Restart the Hyper-V host after driver updates
  8. Verify virtual switch functionality:
    Test-NetConnection -ComputerName "VMName" -Port 3389
Pro tip: Enable Hyper-V event logging at verbose level to capture detailed driver interaction information during troubleshooting.
04

Analyze System Resources and Performance Counters

Investigate system resource constraints that may prevent successful virtual switch port allocation.

  1. Check system memory usage and virtual switch resource consumption:
    Get-Counter "\Memory\Available MBytes", "\Processor(_Total)\% Processor Time"
    Get-Counter "\Hyper-V Virtual Switch(*)\*"
  2. Examine Hyper-V host resource allocation:
    Get-VMHost | Select-Object LogicalProcessorCount, MemoryCapacity, VirtualMachineMigrationEnabled
    Get-VM | Measure-Object -Property MemoryAssigned -Sum
  3. Monitor virtual switch performance during VM startup:
    $Counters = @(
        "\Hyper-V Virtual Switch(*)\Packets/sec",
        "\Hyper-V Virtual Switch(*)\Bytes/sec"
    )
    Get-Counter -Counter $Counters -SampleInterval 5 -MaxSamples 10
  4. Check for memory pressure indicators:
    Get-WinEvent -FilterHashtable @{LogName='System'; Id=2004,2019,2020} -MaxEvents 50
  5. Verify network adapter buffer settings in registry:
    $AdapterPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}"
    Get-ChildItem $AdapterPath | ForEach-Object {
        Get-ItemProperty $_.PSPath | Select-Object DriverDesc, *Buffer*
    }
  6. Increase virtual switch buffer sizes if necessary and restart the host
Warning: Modifying network adapter buffer settings requires careful testing as incorrect values can cause system instability.
05

Advanced Registry and WMI Troubleshooting

Perform deep-level troubleshooting using registry analysis and WMI queries to identify underlying virtual switch database corruption.

  1. Export Hyper-V virtual switch registry settings for analysis:
    $RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\VirtualSwitch"
    Reg export "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization" C:\temp\hyperv-reg-backup.reg
  2. Query WMI for virtual switch configuration details:
    Get-WmiObject -Namespace "root\virtualization\v2" -Class Msvm_VirtualEthernetSwitch | Select-Object ElementName, EnabledState, HealthState
    Get-WmiObject -Namespace "root\virtualization\v2" -Class Msvm_EthernetPortAllocationSettingData
  3. Check for orphaned virtual switch ports:
    $AllPorts = Get-WmiObject -Namespace "root\virtualization\v2" -Class Msvm_EthernetSwitchPort
    $AllPorts | Where-Object {$_.ElementName -eq ""} | Select-Object Name, ElementName
  4. Validate virtual switch database integrity:
    $VSwitchService = Get-WmiObject -Namespace "root\virtualization\v2" -Class Msvm_VirtualEthernetSwitchManagementService
    $VSwitchService.ValidateVirtualSystemConfiguration()
  5. Reset virtual switch WMI namespace if corruption is detected:
    Stop-Service vmms -Force
    winmgmt /resetrepository
    Start-Service vmms
  6. Recreate virtual switch configuration from backup:
    Import-Csv C:\temp\vmswitch-backup.csv | ForEach-Object {
        New-VMSwitch -Name $_.Name -NetAdapterName $_.NetAdapterInterfaceDescription
    }
Pro tip: Use Process Monitor (ProcMon) to capture real-time registry and file system access during virtual switch operations to identify specific failure points.

Overview

Event ID 5120 fires when the Hyper-V Virtual Machine Management Service cannot establish a connection between a virtual machine's network adapter and a virtual switch port. This error typically occurs during VM startup, network adapter configuration changes, or when applying new virtual switch settings. The event indicates that the Hyper-V networking subsystem encountered a critical failure that prevents proper network connectivity for the affected virtual machine.

This event appears in the Microsoft-Windows-Hyper-V-VmSwitch/Operational log and often correlates with VM network connectivity issues. The failure can stem from insufficient system resources, corrupted virtual switch configurations, driver conflicts, or hardware-level networking problems. Understanding this event is crucial for Hyper-V administrators managing virtualized environments where network connectivity is essential for VM operations.

The event typically includes details about the specific virtual machine, network adapter, and virtual switch involved in the failed connection attempt. Investigating this event requires examining both the Hyper-V management logs and the underlying Windows networking subsystem to identify the root cause and implement appropriate remediation strategies.

Frequently Asked Questions

What does Event ID 5120 mean in Hyper-V environments?+
Event ID 5120 indicates that the Hyper-V Virtual Machine Management Service failed to connect a virtual machine's network adapter to a virtual switch port. This error prevents the VM from establishing network connectivity and typically occurs during VM startup, network configuration changes, or when applying virtual switch settings. The event signifies a critical failure in the Hyper-V networking subsystem that requires immediate attention to restore VM network functionality.
Can Event ID 5120 cause complete VM network isolation?+
Yes, Event ID 5120 can result in complete network isolation for the affected virtual machine. When this event occurs, the VM loses all network connectivity, including access to other VMs, the host system, and external networks. This isolation can cause application timeouts, service disruptions, and potential data loss in business-critical environments. The VM may appear to be running normally but will be unable to communicate over the network until the virtual switch connection issue is resolved.
How do I prevent Event ID 5120 from recurring in production environments?+
To prevent Event ID 5120 recurrence, implement several proactive measures: regularly update network drivers and Hyper-V integration services, monitor system resource utilization to prevent overcommitment, maintain proper virtual switch configurations with documented backup procedures, implement network redundancy with multiple virtual switches, schedule regular health checks of virtual switch components, and establish monitoring alerts for Hyper-V networking events. Additionally, ensure adequate system memory and CPU resources are available for virtual switch operations during peak usage periods.
What system resources are most commonly associated with Event ID 5120 failures?+
Event ID 5120 failures are most commonly associated with insufficient system memory, CPU overutilization, and network adapter resource exhaustion. The Hyper-V virtual switch requires dedicated memory buffers for packet processing and port allocation, which can be depleted during high network traffic or when too many VMs are running simultaneously. Physical network adapter limitations, such as insufficient receive buffers or outdated drivers, can also trigger this event. Monitor memory usage, processor utilization, and network adapter performance counters to identify resource constraints that may lead to virtual switch connection failures.
Should I be concerned about Event ID 5120 occurring during VM live migration?+
Yes, Event ID 5120 during live migration is particularly concerning as it can cause migration failures and potential VM downtime. During live migration, virtual machines must maintain network connectivity while transferring between hosts, and virtual switch connection failures can interrupt this process. This can result in failed migrations, VM state corruption, or extended downtime while manually recovering the VM on the original host. Ensure both source and destination hosts have adequate resources, compatible virtual switch configurations, and stable network connectivity before attempting live migrations to minimize the risk of Event ID 5120 occurrences.
Documentation

References (2)

Emanuel DE ALMEIDA
Written by

Emanuel DE ALMEIDA

Senior IT Journalist & Cloud Architect

Microsoft MCSA-certified Cloud Architect | Fortinet-focused. I modernize cloud, hybrid & on-prem infrastructure for reliability, security, performance and cost control - sharing field-tested ops & troubleshooting.

Discussion

Share your thoughts and insights

You must be logged in to comment.

Loading comments...