io.engine undefined? #5376
              
                
                  
                  
                    Answered
                  
                  by
                    darrachequesne
                  
              
          
                  
                    
                      SupertigerDev
                    
                  
                
                  asked this question in
                Q&A
              
            -
| Am I being an idiot? why is io.engine undefined? in the docs, it says i can use  https://stackblitz.com/edit/node-3y7mbxtu?file=index.js v4.8.1 | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            darrachequesne
          
      
      
        Aug 10, 2025 
      
    
    Replies: 1 comment 2 replies
-
| Hi! 
 import { createServer } from "node:http";
import { Server } from "socket.io";
const httpServer = createServer();
const io = new Server(httpServer);
httpServer.on("upgrade", (req, socket, head) => {
  if (req.url.startsWith("/socket.io/")) {
    io.engine.handleUpgrade(req, socket, head);
  } else {
    socket.destroy();
  }
});
httpServer.listen(3000);Reference: https://socket.io/docs/v4/server-api/#enginehandleupgraderequest-socket-head | 
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
It's possible, but a bit more verbose: