title: Http post request error in flutter but work in postman
body: <p>I am learning login registration using mongodb atlas. But I am facing some problems. When i send http post requests for creating new user in emulator its not working and throw some errors. But the same thing works in postman. I can easily create new user in postman. can anyone help me out with this problem?? I am giving my code and error here.</p>
  <pre><code>Future signup(email, password) async {
    var url = Uri.parse(&quot;http://localhost:5050/signup&quot;); // iOS
    final http.Response response = await http.post(
      url,
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
      },
      body: json.encode({
        'email': email,
        'password': password,
      }),
    );
    print(response.body);
  }
  </code></pre>
  <p>this is my server file:</p>
  <pre><code>const express = require('express')
  const app = express()
  
  const port = 5050
  const mongoose = require('mongoose')
  
  
  async function connectDB(){
      await mongoose.connect('mongodb+srv://imran:123s@cluster0.bupnj.mongodb.net/myFirstDatabase?retryWrites=true&amp;w=majority',
      {useUnifiedTopology: true, useNewUrlParser: true}
      )
      console.log('db connected')
  }
  connectDB()
   
  app.use(express.json({extended: false}))
  
  // app.get('/', (req,   res) =&gt; {
  //   res.send('Hello Backend Server!')
  // })
  
  const schema = new mongoose.Schema({ email: 'string', password: 'string' });
  const User = mongoose.model('User', schema);
  
  app.post('/signup', async (req, res) =&gt; {
    const {email, password} =  req.body;
    // console.log(req.body)
    //console.log(&quot;Email: &quot;+email);
    //console.log(&quot;Password: &quot;+password);
    
  
    let user = new User({
      email,
      password
    })
    console.log(user)
    await user.save()
    res.json({token: &quot;1234567890&quot;})
  
    //return res.send('signup api route!')
  })
  
  app.listen(port, () =&gt; {
    console.log(`Example app listening at http://localhost:${port}`)
  })
  </code></pre>
  <p>this the error i got:</p>
  <pre><code>E/flutter ( 4842): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 55746
  E/flutter ( 4842): #0      _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:677:35)
  E/flutter ( 4842): #1      _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1680:26)
  E/flutter ( 4842): #2      RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
  E/flutter ( 4842): #3      Socket._startConnect (dart:io-patch/socket_patch.dart:1891:22)
  E/flutter ( 4842): #4      Socket.startConnect (dart:io/socket.dart:738:21)
  E/flutter ( 4842): #5      _ConnectionTarget.connect (dart:_http/http_impl.dart:2439:18)
  E/flutter ( 4842): #6      _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2805:12)
  E/flutter ( 4842): #7      _HttpClient._getConnection (dart:_http/http_impl.dart:2810:12)
  E/flutter ( 4842): #8      _HttpClient._openUrl (dart:_http/http_impl.dart:2694:12)
  E/flutter ( 4842): #9      _HttpClient.openUrl (dart:_http/http_impl.dart:2568:7)
  E/flutter ( 4842): #10     IOClient.send (package:http/src/io_client.dart:35:38)
  E/flutter ( 4842): #11     BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:38)
  E/flutter ( 4842): #12     BaseClient.post (package:http/src/base_client.dart:32:7)
  E/flutter ( 4842): #13     post.&lt;anonymous closure&gt; (package:http/http.dart:69:16)
  E/flutter ( 4842): #14     _withClient (package:http/http.dart:164:20)
  E/flutter ( 4842): #15     post (package:http/http.dart:68:5)
  E/flutter ( 4842): #16     signup (package:sampleproject/login.dart:61:40)
  E/flutter ( 4842): #17     _loginState.build.&lt;anonymous closure&gt;.&lt;anonymous closure&gt; (package:sampleproject/login.dart:50:19)
  E/flutter ( 4842): #18     State.setState (package:flutter/src/widgets/framework.dart:1088:30)
  E/flutter ( 4842): #19     _loginState.build.&lt;anonymous closure&gt; (package:sampleproject/login.dart:49:17) 
  E/flutter ( 4842): #20     _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:989:21)
  E/flutter ( 4842): #21     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:193:24)
  E/flutter ( 4842): #22     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:608:11)E/flutter ( 4842): #23     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:296:5)E/flutter ( 4842): #24     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:267:7)
  E/flutter ( 4842): #25     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)     
  E/flutter ( 4842): #26     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:444:20)  
  E/flutter ( 4842): #27     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:420:22)E/flutter ( 4842): #28     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:278:11)
  E/flutter ( 4842): #29     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
  E/flutter ( 4842): #30     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
  E/flutter ( 4842): #31     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
  E/flutter ( 4842): #32     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
  E/flutter ( 4842): #33     _rootRunUnary (dart:async/zone.dart:1444:13)
  E/flutter ( 4842): #34     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
  E/flutter ( 4842): #35     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
  E/flutter ( 4842): #36     _invoke1 (dart:ui/hooks.dart:185:10)
  E/flutter ( 4842): #37     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:293:7)
  E/flutter ( 4842): #38     _dispatchPointerDataPacket (dart:ui/hooks.dart:98:31)
  E/flutter ( 4842):
  </code></pre>