Can I use dfx or something to recreate a local wallet canister?

It is assumed that once the local node has been started and the wallet has been created, e.g. by dfx deploy; if the local node is restarted, the wallet id is still saved, but there is no wallet.

dfx identity get-wallet --network http://localhost:4943
bnz7o-iuaaa-aaaaa-qaaaa-cai

dfx identity get-wallet --network http://127.0.0.1:4943
bkyz2-fmaaa-aaaaa-qaaaq-cai

dfx wallet balance --network http://127.0.0.1:4943 
Error: Failed to setup wallet caller.
Caused by: Failed to setup wallet caller.
  Failed to construct wallet canister caller: The replica returned a rejection error: reject code DestinationInvalid, reject message IC0301: Canister bkyz2-fmaaa-aaaaa-qaaaq-cai not found, error code Some("IC0301")

dfx wallet balance --network http://localhost:4943
Error: Failed to setup wallet caller.
Caused by: Failed to setup wallet caller.
  Failed to construct wallet canister caller: The replica returned a rejection error: reject code DestinationInvalid, reject message IC0301: Canister bnz7o-iuaaa-aaaaa-qaaaa-cai not found, error code Some("IC0301")

Is it possible to put the wallet again for the id that can be obtained here?
Or is it possible to recreate everything, including the wallet id itself?

The issue is that if you use the URL then dfx will assume that the same network is still running. If you drop --network or use --network local then dfx will know that it’s the local replica and that it has restarted and will know to automatically create a new wallet.

If you want dfx to re-create a wallet for a manually specified network, you need to make dfx forget about the wallet. You do this by removing the identities.<identity name>.<network name> key from the wallets.json file for that network (or the file entirely). You can find it roughly like this:

MacOS: ~/Library/Application Support/org.dfinity.dfx/network/<something that resembles the URL> Linux: ~/.local/share/dfx/network/`

I see, I understand it very well.
What does --network local mean by local? Is it mapped to a specific url?

local is the network that is selected if you don’t explicitly specify a network, and it maps to localhost:4943 unless you redefine it explicitly

I understand well.
For local development, it seems better to specify -network local instead of --network (url).

Yes, --network local is better than --network <url>, but completely skipping the flag is most convenient