Skip to content

🐛 Bug Report: AppwriteException: null, Connection refused (0) #142

@jebinshaju

Description

@jebinshaju

👟 Reproduction steps

When i was trying to create a todo app with flutter and appwrite , i was not able to register new users .

main.dart

import 'package:flutter/material.dart';

import 'homepage.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Todo App',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: const Homepage(),
    );
  }
}

auth.dart

import 'package:appwrite/appwrite.dart';

Client client = Client()
    .setEndpoint('http://localhost/v1')
    .setProject('64392f2ec924b428ae8c')
    .setSelfSigned(
        status: true); // For self signed certificates, only use for development

//create an user account

Account account = Account(client);

Future createUser() async {
  final user = await account.create(
      userId: ID.unique(),
      email: 'me@appwrite.io',
      password: 'password',
      name: 'My Name');
  print("New User created");
}

homepage.dart

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:todo_app/auth.dart';

class Homepage extends StatelessWidget {
  const Homepage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
      child: TextButton(
        child: const Text("Create User"),
        onPressed: () {
          createUser();
        },
      ),
    ));
  }
}

error i am getting

Launching lib\main.dart on Android SDK built for x86 in debug mode...
main.dart:1
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:61863/095xhGqFJ90=/ws
E/flutter ( 5774): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: AppwriteException: null, Connection refused (0)
E/flutter ( 5774): #0      ClientIO.call
client_io.dart:381
E/flutter ( 5774): <asynchronous suspension>
E/flutter ( 5774): #1      Account.create
account.dart:53
E/flutter ( 5774): <asynchronous suspension>
E/flutter ( 5774): #2      createUser
auth.dart:14
E/flutter ( 5774): <asynchronous suspension>
E/flutter ( 5774):

👍 Expected behavior

It should have created a new user and report it in the appwrite page

👎 Actual Behavior

image

Error i am getting

Launching lib\main.dart on Android SDK built for x86 in debug mode...
main.dart:1
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:61863/095xhGqFJ90=/ws
E/flutter ( 5774): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: AppwriteException: null, Connection refused (0)
E/flutter ( 5774): #0      ClientIO.call
client_io.dart:381
E/flutter ( 5774): <asynchronous suspension>
E/flutter ( 5774): #1      Account.create
account.dart:53
E/flutter ( 5774): <asynchronous suspension>
E/flutter ( 5774): #2      createUser
auth.dart:14
E/flutter ( 5774): <asynchronous suspension>
E/flutter ( 5774):

🎲 Appwrite version

Version 2.0.x

💻 Operating system

Windows

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions