Socket Io not working

Hello, I’m implementing Socket io in my ionic project. But having an issue, while creating an apk and running that on Android version 5 and 6 i’m getting an error in console undefined identifier. While running same apk on Android 7+ its working fine.
While debugging the error i found the error in app.module.ts file:

import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
const config: SocketIoConfig = { url: 'http://localhost:81', options: {} };

imports: [BrowserModule, HttpClientModule, IonicModule.forRoot(), AppRoutingModule, SocketIoModule.forRoot(config) ],

Having error in these. When i comment out these its working fine in all version of Android.
In web view its working fine while commenting and uncommenting these lines.